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 > How to return value from script and display information

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-11-11, 02:41
amcc38 amcc38 is offline
Registered User
 
Join Date: Oct 2011
Posts: 12
Question How to return value from script and display information

Dear Sir,

I want to know how to return 0/-1 from sql to ksh script. My sql need to be called from unix script. Then, some checking will be proceed in sql, and return -1 if checking result is abnormal. Also, I need to display information during checking, but it doesn't work

My program as below.

in ksh.
db2 "set serveroutput on"
db2 -td/ +o -f test.sql << EOF1 2>&1
$x1
EOF1
if [ $? -eq 0 ]
then
echo 'ok'
else
echo 'failed'
fi
--------

In sql,
Begin
Declare ....

select count(*) from ....
call dbms_output.put_line(count);
if count > 0 then
return -1
else
retrurn 0
end if
end
-------------------

Please kindly to let me know what wrong of above program. Thanks !
Reply With Quote
  #2 (permalink)  
Old 11-11-11, 08:10
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by amcc38 View Post
Also, I need to display information during checking, but it doesn't work
What do you mean by "doesn't work"? Does your SQL script produce the desired output when run alone manually? Consider also posting the actual code, not your interpretation of what is important.
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