Check the value from Table


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check the value from Table
# 1  
Old 09-10-2014
Hammer & Screwdriver 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 shell script for this logic.Table can be accessed from the script by select statement.
# 2  
Old 09-10-2014
What have you tried to fulfill your requirements?
# 3  
Old 09-10-2014
Hi
Haven't tried as such from scripting side looking for some guidance.Thanks!
# 4  
Old 09-10-2014
Hi,

You seem to be suggesting a call to sql from inside a shell script, or am I missing some thing - do you have an example?

Regards

dave
# 5  
Old 09-10-2014
Hi,
yes I am trying to read column value from table with sql statement.it will direct call like db2 "select col_name from table"
# 6  
Old 09-10-2014
Try
Code:
val=`sqlplus -s <<ESQL
${DB_LOGON}
set serveroutput off
set heading off
set feedback off
set verify off
set define off
select col_name from table;
exit
ESQL`
 
while true; do
        if [ $val == "N" ]; then
                start_main_script
    sleep 1800
        else
                stop_server
                break;
        fi
done

Notestart_main_script & stop_server functions must be written above this code

Last edited by Makarand Dodmis; 09-10-2014 at 08:22 AM..
# 7  
Old 09-10-2014
Hi,

Then it is likely that you will have to follow these steps.
  1. Ensure that the script has the correct envirinment.
  2. Pass the output from your select statement to a variable or file.
  3. Parse the variable or file and check the value.
  4. If the value is true perform the action.

Regards

Dave
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Web Development

Getting Rid of Annoying Bootstrap Table Borders and Wayward Table Lines

Bootstrap is great; but we have had some issues with Bootstrapped <tables> (and legacy <fieldset> elements) showing annoying, wayward lines. I solved that problem today with this simple jQuery in the footer: <script> $(function(){ $('tr, td, fieldset,... (0 Replies)
Discussion started by: Neo
0 Replies

2. Programming

DB2 Query to check table counts,start end time

Dear team I am using DB2 and wish to capture the ETL status on daily basis so that i can run the query and share the details in xls format to respective mail ids . Currently i am using below query but this displays table name and counts for latest run. select name ,CARD from... (0 Replies)
Discussion started by: Perlbaby
0 Replies

3. 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

4. Shell Programming and Scripting

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... (5 Replies)
Discussion started by: katled
5 Replies

5. Shell Programming and Scripting

Build a table from a list by comparing existing table entries

I am new to this shell scripting.... I have a file which contains list of users. This files get updated when new user comes into the system. I want to create script which will give a table containing unique list of users. When I say unique, it means script should match table while parsing... (3 Replies)
Discussion started by: dchavan1901
3 Replies

6. UNIX for Dummies Questions & Answers

Creating a condensed table from a pre-existing table in putty

Hello, I'm working with putty on Windows 7 professional and I'd like to know if there's a way to gather specific lines from a pre-existing table and make a new table with that information. More specifically, I'd like the program to look at a specific column, say column N, and see if any of the... (5 Replies)
Discussion started by: Deedee393
5 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

select values from db1 table and insert into table of DB2

Hi I am having three oracle databases running in three different machine. their ip address is different. from one of the DB am able to access both the databases.(means am able to select values and insert values in to tables individually.) I need to fetch some data from DB1 table(say DB1 ip is... (2 Replies)
Discussion started by: aemunathan
2 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 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

10. 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
Login or Register to Ask a Question