LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Other *NIX (http://www.linuxquestions.org/questions/other-%2Anix-55/)
-   -   how do i know sql command is executed or not in unix? (http://www.linuxquestions.org/questions/other-%2Anix-55/how-do-i-know-sql-command-is-executed-or-not-in-unix-4175449276/)

alavala53 02-09-2013 04:36 AM

how do i know sql command is executed or not in unix?
 
i want to insert new record based on if below record inserted into table.how do i know query is executed or not? please look the below query for reference in unix.

sqlplus -s bscsadm@bscspr/bs#s7Ta0m << EOF
insert into $1 values('ram',222,'hyd');
EOF

Ser Olmy 02-09-2013 06:55 AM

"Unix" is not executingthat SQL query, the sqlplus executable is.

Most commands return a non-zero exit code if an error condition occurred. Try checking the $? variable immediately after running sqlplus.

onebuck 02-09-2013 07:44 AM

Moderator Response
 
Moved: This thread is more suitable in <Other *NIX> and has been moved accordingly to help your thread/question get the exposure it deserves.

scottbro 02-10-2013 03:51 AM

Quote:

Originally Posted by Ser Olmy (Post 4887558)
"Unix" is not executingthat SQL query, the sqlplus executable is.

Most commands return a non-zero exit code if an error condition occurred. Try checking the $? variable immediately after running sqlplus.

You left out a bit of detail. You can check the $? variable by running this in a terminal as root.
Code:

// harmful shell statement removed.

colucix 02-10-2013 08:32 AM

Please, ignore the post above. It will be deleted soon.

crabboy 02-12-2013 08:31 AM

You may have problems with your statement depending on if sqlplus will auto commit your transaction when you exit. I think the default behavior is to rollback any changes. You would likely have to add a commit; after your insert statement.

I'd be best to capture an error condition in your script and set the exit code when your script terminates. Search around for sqlplus exit code.


All times are GMT -5. The time now is 03:19 PM.