The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
return DB2 SQLCODE kjaisan Shell Programming and Scripting 0 11-16-2005 10:00 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-14-2008
Read Only
 

Join Date: Oct 2008
Posts: 9
how to get SQLCODE ?

Suppose I am executing a sql query thru shell script.
DB : IBM DB2

Quote:
db2 "select * from table1 with ur"
If none of the rows are fetched, I will be getting the sql code as 100
If rows > 0 are fetched, I will be getting the sqlcode as 0

Can any one help me how to get this SQL code in unix shell script (in KSH)

Krishnakanth
Reply With Quote
Forum Sponsor
  #2  
Old 10-14-2008
Moderator
 

Join Date: Sep 2007
Location: Germany
Posts: 1,031
I don't know the syntax with "WITH", only with "WHERE", etc.
If you db2 SQL query finds at least 1 row, the returncode of your command will be 0, if not it is 1 or at least > 0.
So you can work with testing $? or parse whatever SQL code you are getting by putting your command into a variable maybe like for example
Code:
VAR=`db2 "select something from sometable..."`
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 03:38 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0