473,748 Members | 2,690 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Return status from a stored pros in a OS script

Is there a way to check the return status from a stored procedure when
called from a OS (Windows) script?

I have a stored procedure that does some checking in the database, and the
return status is set to 0 or -1 if 'OK' or 'not OK' respectively.

When I call the from CLP I get something like this:

Value of output parameters
--------------------------
Parameter Name : P_SQLSTATE
Parameter Value : 00000

Parameter Name : P_MESSAGE
Parameter Value :

Return Status = 0

I want to do this in my script:
db2 call proc(?, ?)
if RC= 0 then do something
else then do something else

If I run this script from the Task Center, is there a way to 'force' the
task to fail if the return status is not 0 ?

Regards
Odd B Andersen
ErgoGroup AS, Oslo, Norway
May 24 '07 #1
3 5202
Odd Bjørn Andersen wrote:
Is there a way to check the return status from a stored procedure when
called from a OS (Windows) script?

I have a stored procedure that does some checking in the database, and the
return status is set to 0 or -1 if 'OK' or 'not OK' respectively.

When I call the from CLP I get something like this:

Value of output parameters
--------------------------
Parameter Name : P_SQLSTATE
Parameter Value : 00000

Parameter Name : P_MESSAGE
Parameter Value :

Return Status = 0

I want to do this in my script:
db2 call proc(?, ?)
if RC= 0 then do something
else then do something else
I don't think that the exit status from the CLP is related to the return
status of a stored procedure. Therefore, you will have to parse the output
and act on the parsed result. Alternatively, you can write a small program
that invokes your procedure and uses the return status of the CALL as its
own exit status.

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
May 25 '07 #2
On May 24, 9:53 am, "Odd Bjørn Andersen" <oba...@online. nowrote:
Is there a way to check the return status from a stored procedure when
called from a OS (Windows) script?

I have a stored procedure that does some checking in the database, and the
return status is set to 0 or -1 if 'OK' or 'not OK' respectively.

When I call the from CLP I get something like this:

Value of output parameters
--------------------------
Parameter Name : P_SQLSTATE
Parameter Value : 00000

Parameter Name : P_MESSAGE
Parameter Value :

Return Status = 0

I want to do this in my script:
db2 call proc(?, ?)
if RC= 0 then do something
else then do something else

If I run this script from the Task Center, is there a way to 'force' the
task to fail if the return status is not 0 ?

Regards
Odd B Andersen
ErgoGroup AS, Oslo, Norway

It depends on the scripting language that you use on Windows.

You must parse the output of the CLP invokation "db2 call ..." to
search for "Return Status = 0".

With scripting tools like Perl or *nix-like shells (like Ksh or Bash)
under Cygwin - you have more power to parse text.

If your only tool is basic CMD.EXE script language, then something
like this hack will work on Win/XP.

....
db2 "CALL your_procedure( ...)" 2>&1 1>spcall.log
@rem the find command returns 0 when the string is found
find "Return Status = 0" spcall.log null
@if ERRORLEVEL 1 goto :nonzero_status
:success_status
....whatever

:nonzero_status
....whatever

May 25 '07 #3
>"mike" <_l*****@yahoo. comwrote in message
news:11******* *************** @k79g2000hse.go oglegroups.com. ..
On May 24, 9:53 am, "Odd Bjørn Andersen" <oba...@online. nowrote:
>Is there a way to check the return status from a stored procedure when
called from a OS (Windows) script?

I have a stored procedure that does some checking in the database, and the
return status is set to 0 or -1 if 'OK' or 'not OK' respectively.

When I call the from CLP I get something like this:

Value of output parameters
--------------------------
Z Parameter Name : P_SQLSTATE
Parameter Value : 00000

Parameter Name : P_MESSAGE
Parameter Value :

Return Status = 0

I want to do this in my script:
db2 call proc(?, ?)
if RC= 0 then do something
else then do something else

If I run this script from the Task Center, is there a way to 'force' the
task to fail if the return status is not 0 ?

Regards
Odd B Andersen
ErgoGroup AS, Oslo, Norway


It depends on the scripting language that you use on Windows.

You must parse the output of the CLP invokation "db2 call ..." to
search for "Return Status = 0".

With scripting tools like Perl or *nix-like shells (like Ksh or Bash)
under Cygwin - you have more power to parse text.

If your only tool is basic CMD.EXE script language, then something
like this hack will work on Win/XP.

...
db2 "CALL your_procedure( ...)" 2>&1 1>spcall.log
@rem the find command returns 0 when the string is found
find "Return Status = 0" spcall.log null
@if ERRORLEVEL 1 goto :nonzero_status
:success_statu s
...whatever

:nonzero_statu s
...whatever
Yes, that worked just fine!

Thank you very much.

Regards
Odd B
May 29 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1913
by: Eugene | last post by:
Hi Is it possible to use Visual Source Safe with SQL Server in order to keep track of all modifications done to stored procedures? What are the pros and cons ? Thanks, Eugene
2
2821
by: scott | last post by:
Hi, Just wondering what sort of problems and advantages people have found using stored procedures. I have an app developed in VB6 & VB.NET and our developers are starting to re-write some of the code in stored procedures (im advocating encryption of them). When deploying an application however stored procedure seem to add another level of complexity to installation. In future we also plan to have an basic ASP app with some of the...
2
4670
by: Rhino | last post by:
I am trying to verify that I correctly understand something I saw in the DB2 Information Center. I am running DB2 Personal Edition V8.2.1 on Windows. I came across the following in the Info Center: To return a result set from a procedure to the originating application, use the WITH RETURN TO CLIENT clause. When WITH RETURN TO CLIENT is specified on a result set, no nested procedures can access the result set.
9
1889
by: Ronald S. Cook | last post by:
What do you guys think of abandoning stored procedures and writhing the SQL in code? I'm a little new to the debate and not sure I totally understand. From my command object, I can just select the type to be "text" instead of "stored procedure", type my SQL there and it performs just the same? When did writing the SQL in code become just as good as using procs? Is there a list of pros/cons someone can forward?
4
7142
by: Jonathan | last post by:
I have a SQL stored procedure for adding a new record in a transactions table. It also has two return values: CounterID and IDKey. I want to create a webservice that accepts the 10 input parameters and returns the two return values. My C# programmer here says that webservice methods can only return 1 value per method. Is that right? Though I haven't ever created a webservice, I would have thought that a method could return a whole lot...
12
5139
by: Dooza | last post by:
I have a stored procedure that takes a number of inputs, does a bulk insert, and then outputs a recordset. When I run the stored procedure in Server Management Studio I also get a return value from the stored procedure which is an INT. I want to access this return value on my ASP/VBScript page, but do not know how to access it. Here is my code so far:
4
2984
by: jleeie | last post by:
Can someone help me, I'm going round in circles with this and my head is cabbaged ! I am using visual studio 2005 & VB & MS SQL 2005 I am trying to execute a stored procedure from within a program. I want to return values. I can get a 0 or 1 returned. I don't seem to be able to get any other value returned. below is my VB code and the stored procedure. I would really appreciate if someone would have a look that knows how to do this....
3
10282
by: devi thapa | last post by:
Hi, I am running one service in the python script eg like "service httpd status". If I execute this command in normal shell kernel, the return code is 3. But in the python script its return code is different, ie not 3, I mean to say that return codes are differing. But I want the return code 3 , not the other one. So, how can I achieve this? Regards,
3
1988
by: tvnaidu | last post by:
This is my build script, I calls this script from main build script, in case of SUCCESS, everything is ok, but in failure, I do "return 1", so that main build can cheque "$?" and based on that it prints success or not, but here "return 1", throwa an error "./build: line 17: return: can only `return' from a function or sourced script", any idea?. I did issue command "cat build" below. any iddue with "return 1"?. $ cat build make clean make...
0
9381
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9332
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8252
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.