The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

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 01:00 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-14-2008
regnumber regnumber is offline
Registered User
  
 

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
  #2 (permalink)  
Old 10-15-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,259
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..."`
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:49 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0