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.

What have you tried to fulfill your requirements?

Hi
Haven't tried as such from scripting side looking for some guidance.Thanks!

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

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"

Try

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

Note start_main_script & stop_server functions must be written above this code

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