LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   update oracle table using shell script (https://www.linuxquestions.org/questions/programming-9/update-oracle-table-using-shell-script-263253/)

ann124 12-06-2004 10:53 AM

update oracle table using shell script
 
Hi,
I would like to know how to update a table in Oracle database, if a command in one shell script either successfully completes or it fails.(like Y if its success or N if its a failure)

While the command is running,I am able to view the log file created in the Unix machine.After the command is exexcuted,it has to update a column in Oracle database . How can I do this?

any ideas or solutions are welcome.

jim mcnamara 12-06-2004 02:42 PM

try something like this:
Code:

UID="user"
PSWD="password"
somevalue="99"

exsql ()  {
    awk '{ if(NR == 1) {
        STR=sprintf("%s/%s",UI,PW)
        print STR
        print "set pagesize 80;"
        print "set linesize 240;"
        }
        print $0}
        END { print "COMMIT;" } ' UI=$UID PW=$PSWD | sqlplus -s
    }
# run my command - returns 0 on success
mycommand 
if [ $? -eq 0 ]; then
  echo "UPDATE MYTABLE SET FLD1=$somevalue" | exsql
fi

Most commands return 0 or 1 in Unix.


All times are GMT -5. The time now is 11:52 PM.