Is there anyway of catching a TPT script run-time error in BTEQ? I call the TPT script from BTEQ by the following command:
.OS /opt/teradata/client/15.10/bin/tbuild -f /opt/TBF/TWS/BIN/VP265CS6/scripts/RTIM_Flexiprofile_Export.tpt
I am calling TPT from BTEQ because we have a utility which would only execute BTEQ scripts.
The SYSTEMRETURNCODE keyword can be used in an IF command condition to check the last OS command's return code for all BTEQ flavors (Linux, Windows etc.). It can also be used for an EXIT command for Windows BTEQ. This was introduced in the following versions and is in all currently supported versions:
Also with the above versions, you can use multiple conditions within one IF command.
And for completeness, just wanted to mention here that with BTEQ 16.20.00.04, conditional instructions can now be scripted using IF, ELSEIF, ELSE and ENDIF commands. And there is also a BRANCHMSG command for terser result block output for instructions skipped during a GOTO or bypassed due to being in a block where the condition checks resolved to false.
Thanks for the correction, @SuzanneA!
So you don't have to upgrade to TTU16.xx for this feature, but if you are on an earlier version you may need to install a more recent TTU maintenance release.
Thanks a lot for your replies. I am on Teradata Version 15.10.07.21. I use the following BTEQ code:
.LOGON $LOGIN$ .IF ERRORCODE != 0 THEN .GOTO ERROR .SET WIDTH 100 .OS /opt/teradata/client/15.10/bin/tbuild -f /opt/TBF/TWS/BIN/VP265CS6/scripts/RTIM_Flexiprofile_Export.tpt .IF SYSTEMRETURNCODE != 0 THEN .GOTO ERROR .EXIT 0 .LABEL ERROR .EXIT ERRORCODE
I am deliberately failing the script by giving a wrong path for the TPT script. The SYSTEMRETURNCODE is not recognized by BTEQ. The error thrown is given below:
.OS /opt/teradata/client/15.10/bin/tbuild -f /opt/TBF/TWS/BIN/VP265CS6/scripts/RTIM_Flexiprofile_Export.tpt Teradata Parallel Transporter Version 15.10.00.00 64-Bit TPT_INFRA: TPT02014: Error: opening job script file '/opt/TBF/TWS/BIN/VP265CS6/scripts/RTIM_Flexiprofile_Export.tpt':"No such file or directory" (2) Job script compilation failed. Job terminated with status 12. *** Warning: System call failed. *** Error: Did not recognize the variable 'SYSTEMRETURNCODE'.
Will appreciate if there is any work around on this.
You will need to upgrade to a newer fix level of TTU 15.10, or to any TTU 16 release.
(Im guessing that 15.10.07.21 is your database version; you don't show your BTEQ version, but it's unlikely to be 15.10.01.02 or later if your TPT is only 15.10.00.00.)