If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > bash - udb scripting error check help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-09-05, 11:17
db2guru1 db2guru1 is offline
Registered User
 
Join Date: Aug 2003
Posts: 106
bash - udb scripting error check help

Server: UDB 8.1 solaris server
Client: Windows xp with bash installed

I am trying a simple test like this..

#!/bin/bash

Echo off

#
# Connect to DB2
#

db2 connect to sample user db2admin using db2admin

db2 -x 'call x_validation_list(?)';

echo $?

if [ $? -ne 0 ]
then
echo "*** stored procedure x_validation_list bad call"
return
fi

echo "the end..."

db2 connect reset

RESULTS
======
Got the following message at c prompt:

Echo: not found

Database Connection Information

Database server = DB2/NT 8.1.6
SQL authorization ID = DB2ADMIN
Local database alias = STGD01

SQL0440N No authorization routine named "X_VALIDATION_LIST" of type "PROCEDURE" having compatible arguments was found. SQLSTATE=42884
4
the end...
DB20000I The SQL command completed successfully

BEHAVIOUR EXPECTED
=================
I was expecting results something like this...

Echo: not found

Database Connection Information

Database server = DB2/NT 8.1.6
SQL authorization ID = DB2ADMIN
Local database alias = STGD01

SQL0440N No authorization routine named "X_VALIDATION_LIST" of type "PROCEDURE" having compatible arguments was found. SQLSTATE=42884
4
*** stored procedure x_validation_list bad call
------------------------------------------------------------

Can somebody tell me why:
1. The if coniditon echo is not being displayed - Echo ? did display 4 which is non zero
2. And the second is really corollary to the above - why did the return not work
3. RETURN in bash will prevent any statements below it to be executed - Is my understanding right?

Now the SP x_validation_list is a non-existing SP; So I was hoping that the echo "*** stored procedure x_validation_list bad call" will be displayed and RETURN will stop the script and get out - meaning I DID NOT expect echo "the end..." to display.

Thanks
__________________

You are the creator of your own destiny!
Reply With Quote
  #2 (permalink)  
Old 03-09-05, 11:47
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
What do you think the value of "$?" is at any given point in time?
Reply With Quote
  #3 (permalink)  
Old 03-09-05, 11:49
db2guru1 db2guru1 is offline
Registered User
 
Join Date: Aug 2003
Posts: 106
Before the if condition I do display $? and it returns 4 - Have I answered your question??
__________________

You are the creator of your own destiny!
Reply With Quote
  #4 (permalink)  
Old 03-09-05, 12:04
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
So, it is "4" after the "db2 ..." command. What do you think it is after the "echo ..." command?
Reply With Quote
  #5 (permalink)  
Old 03-09-05, 12:09
db2guru1 db2guru1 is offline
Registered User
 
Join Date: Aug 2003
Posts: 106
Ok! Got it! Removed Echo and worked like a charm! Thanks N_J :-)
__________________

You are the creator of your own destiny!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On