Check a field in a table


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check a field in a table
# 1  
Old 11-29-2013
Check a field in a table

I have made a table PRD_WORK_LM.test and it contains one field, ctrl_test. This field contains a 0 or a 1. I want to write a unix script that goes like this:

IF ctrl_test = 1 THEN ... ELSE exit FI

How can I write this in a script? Do I have to do this within bteq? or outside bteq? can anyone help me?
# 2  
Old 11-29-2013
Quote:
Originally Posted by katled
I have made a table PRD_WORK_LM.test and it contains one field, ctrl_test. This field contains a 0 or a 1. I want to write a unix script that goes like this:

IF ctrl_test = 1 THEN ... ELSE exit FI

How can I write this in a script? Do I have to do this within bteq? or outside bteq? can anyone help me?
I really didn't understand your requirement .. what table it is ? whether it's table in mysql database ? or plain text file ? please be specific about requirement, and make sure that others will understand the same. It's always good,if you show your input and expected output.
# 3  
Old 11-29-2013
It's a SQL-table.

I tried something like this:
Code:
DATABASE=PRD_WORK_LM ;
TABLE=ctrl_load ;

if [ ${DATABASE}.${TABLE}.load_ok  -eq 1 ]
   then echo "start script"|mailx -s "start `date` " katled@.be
        else echo "stop script'  mailx -s "load nog niet gedaan `date`" katled@.Be
              exit 0
fi

But it didn't work

Last edited by radoulov; 11-29-2013 at 11:04 AM..
# 4  
Old 11-29-2013
It what way did it 'not work'?
# 5  
Old 11-29-2013
Yes, and where's your ctrl_test? You need to select that DB field into a shell variable to be able to "test" it! Search these fora for examples on how to select an SQL field into shell variables; there's plenty of them.
# 6  
Old 11-29-2013
Hi katled...

Maybe I am missing something here but:
Code:
I have made a table PRD_WORK_LM.test.......

Is not the same as:-
Code:
DATABASE=PRD_WORK_LM ;

Where is the ".test" extension?
If you intend to compare something check you have your details correct...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to add subtotal and total according 3rd field mentioned below table?

111AKKK|SHA|20|25 111|AKKK|SHA|15|35 112|ABC|FL|25|45 112|ABC|FL|15|15 115|AKKK|ASH|10|15 115|AKKK|ASH|20|20 112|ABC|FL|25|20 115|AKKK|ASH|30|35 111|AKKK|SHA|10|45 112|ABC|KL|15|15 112|ABC|KL|20|25 115|AKKK|ASH|30|35 please write a shell script output should be below mentioned... (26 Replies)
Discussion started by: udhal
26 Replies

2. Shell Programming and Scripting

Help to check if Oracle table exists

I am trying to write a script which allows a user to select the what manipulation he needs to do on a table. I want to check if the table exists or not. If it exists I will continue the other things or else I exit saying table doesn't exist. How might I achieve this. (1 Reply)
Discussion started by: gmatcat
1 Replies

3. Shell Programming and Scripting

Check the value from Table

Hi I have a requirement like this:A shell script will check a table column if the column name "value" is 'N' then main script start and keep checking within 30 minute whether the column value has changed to 'y'. or not if it has changed to 'y' then stop the server.Please help me to get the... (6 Replies)
Discussion started by: netdbaind
6 Replies

4. UNIX for Dummies Questions & Answers

Combine table field for time

Hi, I have table like usrid Month Date year Time w23da Feb 10 2014 12:42:34 ae3aw Feb 20 2014 12:47:02 zse3q Feb 09 2014 10:02:28 all the five fields are inserted into different columns I want to combine all four (Month,Date,year and Time) and make it... (4 Replies)
Discussion started by: stew
4 Replies

5. Shell Programming and Scripting

Converting form field to table format

May data Name = Andi Address = none Phone = 82728 Name = Peter Address = none Phone = 98799 The expected output Name,Address,Phone Andi,none,82728 Peter,none,98799 what i have done (6 Replies)
Discussion started by: before4
6 Replies

6. Shell Programming and Scripting

Adding a field to a file using a conversion table

Hello everyone, Here is what i am trying to accomplish. I have a transaction log that I want to to add a field. The fields in the transaction log are tab delimited FYI. My goal is to add a column specifying the category/type to each item purchased. I have created a two column "conversion table"... (2 Replies)
Discussion started by: SpencerClark
2 Replies

7. UNIX for Dummies Questions & Answers

To check, a table is used in a job

Hi, I have a list of jobs scheduled in unix. I want to check whether a particular view or table is used in a job. If they are not used, I can make changes to them. Thanks, Raaga (2 Replies)
Discussion started by: Raaga
2 Replies

8. Shell Programming and Scripting

Check the record count in table (table in oracle)

I have requirement: 1) Check the record count in table (table in oracle) 2) If records exists generate the file for existing records and wait for some time then Go to sleep mode and Again check the record count after 10 min.......... (Loop this process if record count >0). 3) Generate touch... (1 Reply)
Discussion started by: kamineni
1 Replies

9. Shell Programming and Scripting

Check the record count in table (table in oracle)

I have requirement: 1) Check the record count in table (table in oracle) 2) If records exists generate the file for existing records and wait for some time (Go to sleep mode) and Again check the record count after 10 min.......... (Loop this process if record count >0). 3) Generate touch... (1 Reply)
Discussion started by: kamineni
1 Replies

10. Shell Programming and Scripting

create new table/field

Dear Folks, If I have 2 files, say A and B in format: A: $1 $2 01032 12856 01041 13351 01042 11071 01042 12854 01042 12862 01042 12866 . . . and B: (2 Replies)
Discussion started by: Gr4wk
2 Replies
Login or Register to Ask a Question