Printing error messages
The following code formats and prints SQL error messages to the SYSTSPRT data set when the product is running in batch mode or TSO:
rc = pssrxsql("select current_timestamp into :TS from sysibm.sysdummy1")
if rc <> 0 then do
msg = "BMC184001S-PSSREXIT rc=" || rc || "/n"
if sqlcode <> 0 then do i = 1 to 1000 by 80
m = substr(sqlerrm,i+1,79)
if m = ' ' then leave
msg = msg || "BMC184001S-" || m || "/n"
end
rc = sets("OUT", msg)
end
if rc <> 0 then do
msg = "BMC184001S-PSSREXIT rc=" || rc || "/n"
if sqlcode <> 0 then do i = 1 to 1000 by 80
m = substr(sqlerrm,i+1,79)
if m = ' ' then leave
msg = msg || "BMC184001S-" || m || "/n"
end
rc = sets("OUT", msg)
end
You can use the REXX variable SQLSTATE instead of SQLCODE. SQLSTATE indicates both warnings and errors.
If the product issues a warning without an error, PSSRXSQL returns rc=0, SQLCODE=0, ignoring warnings so that all the row values are returned. If you want to inspect warnings, use the SQLSTATE variable.
Related topic
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*