LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Other *NIX
User Name
Password
Other *NIX This forum is for the discussion of any UNIX platform that does not have its own forum. Examples would include HP-UX, IRIX, Darwin, Tru64 and OS X.

Notices

Reply
 
Search this Thread
Old 02-09-2013, 04:36 AM   #1
alavala53
LQ Newbie
 
Registered: Oct 2012
Location: Hyderabad
Posts: 10

Rep: Reputation: Disabled
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
 
Old 02-09-2013, 06:55 AM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 1,919

Rep: Reputation: Disabled
"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.
 
Old 02-09-2013, 07:44 AM   #3
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 11,044
Blog Entries: 1

Rep: Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369
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.
 
Old 02-10-2013, 03:51 AM   #4
scottbro
LQ Newbie
 
Registered: Dec 2012
Posts: 3

Rep: Reputation: 0
Quote:
Originally Posted by Ser Olmy View Post
"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.

Last edited by crabboy; 02-12-2013 at 08:26 AM.
 
Old 02-10-2013, 08:32 AM   #5
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
Please, ignore the post above. It will be deleted soon.
 
Old 02-12-2013, 08:31 AM   #6
crabboy
Moderator
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
ShellScript executed from command prmpt but not executed from crontab or at command BMMadhav Linux - Newbie 1 11-16-2012 07:20 PM
How to run sql programs in Unix Env? anandv_1234 Linux - Newbie 3 02-12-2008 11:28 AM
time when a command was executed. anandkj Linux - Newbie 3 12-21-2007 01:09 AM
how to see which command has been executed ? Volcano Linux - Newbie 4 12-11-2006 08:48 AM
How to set SQL to UNIX socket Skunk_Face Linux - General 1 01-19-2004 06:20 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration