LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-06-2004, 10:53 AM   #1
ann124
LQ Newbie
 
Registered: Nov 2004
Posts: 9

Rep: Reputation: 0
Lightbulb 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.
 
Old 12-06-2004, 02:42 PM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
Way to update mysql table 200+ times at once macie Programming 7 04-13-2005 11:45 PM
write an update query in shell prompt to update the database in sqlserver suchi_s Programming 2 09-29-2004 07:27 AM
Unable to update kernel routing table TrashCanMan Linux - Wireless Networking 2 03-07-2004 04:03 AM
mySQL table update DropHit Linux - Software 5 02-04-2004 10:47 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration