To capture the return code in BTEQ

Database
Enthusiast

To capture the return code in BTEQ

Hi,

if i want to capture the returncode of the following stmt how do i do that in BTEQ .
Env:UNIX. Parent.btq is running the logon.txt

.Run File logon.txt
-- say suppose the file logon.txt itself doesnot exist, how do i capture the the return code in BTEQ
-- even though the file is not present the return code of the parent.btq is zero. Strange!!

inputs please.
7 REPLIES
Enthusiast

Re: To capture the return code in BTEQ


you may want to look up the errorcode and errorlevel variables in bteq manual and explore the ways in which you can use it with the .IF control construct in bteq to accomplish what you want.
Enthusiast

Re: To capture the return code in BTEQ

try that :

.run file logon.txt
.if errorcode > 0 then .quit 255

your bteq return code will be 255 if login fails
Enthusiast

Re: To capture the return code in BTEQ

Hi,

I had tried doing that before but it wont work: Here is a part of the logfile

.run file a.txt
*** Error: Open failed because: No such file or directory
+---------+---------+---------+---------+---------+---------+---------+----
.if errorcode > 0 then .quit 255
+---------+---------+---------+---------+---------+---------+---------+----
sel 1;

*** Query completed. One row found. One column returned.
*** Total elapsed time was 1 second.

1
----
1
+---------+---------+---------+---------+---------+---------+---------+----

.logoff;
*** You are now logged off from the DBC.
+---------+---------+---------+---------+---------+---------+---------+----
.exit
*** Exiting BTEQ...
*** RC (return code) = 0

eventhough a.txt is not present the script didnt quit it ran successfully ...

any idea?
SN
Enthusiast

Re: To capture the return code in BTEQ

hi,

is this is the first stmt in your script? If not, what could be possible is, you were logged with a valid log file at top and execute few stmts and have this logon stmt in the middle of your script without loggin off from previously established session. There is no way the sql stmt can execute without a connection established.

thx
Enthusiast

Re: To capture the return code in BTEQ

Hi,

The logon was just an example that i gave. a.txt is present in the middle of the Bteq script.
There were some Sql that had to be run in a.txt

But any idea how to handle File not found in Bteq.
SN
Enthusiast

Re: To capture the return code in BTEQ

hi,

BTEQ will fail with the utility error code 'UTY4802'. this is on MVS though....

"UTY4802 Unable to open file .
Explanation: An invalid file name or ddname has been specified.
Generated By: UMBSTMIN "

if its not failing then check if there is a overide in the script which suppressess this errorcode to severity 0.

thx,
Enthusiast

Re: To capture the return code in BTEQ

AFAIK, errorcodes work with only the actual database errors (like table not found etc), not with bteq errors itself (like file not found...)... but then you can check if the file exists or not in advance using a wrapper shell script ?