The SQL error procedure
The SQL error procedure
129 /*--------------------------------------------------------------------
130
131 sqlerror - output sql error codes and messages
132
133 --------------------------------------------------------------------*/
134
135 sqlerror:
136 say 'ASURXSQL return code = 'rc;
137
138 if sqlcode ¬= 0 then do i = 1 to 1000 by 80
139 m = substr(sqlerrm,i+1,79)
140 if m = ' ' then leave
141 say m
142 end
143
Line Number | Description |
---|---|
129-133 | These lines are comments. |
135 | This line marks the beginning of the SQL error procedure, which runs if any of the following error conditions occur:
|
136 | This line returns the SQL error return code in the format ASURXSQL return code = rc |
138-141 | These lines check for an SQL error, and if one is present, divide the message into 80-byte segments and output the SQL error message. |
138 | If the product finds a nonzero SQL code, this line increments the variable i (loop counter) by 80. |
139 | This line returns a substring of the SQL error message ( sqlerrm) text. This instruction divides the message into 80-byte segments and assigns the resulting message to the variable m. |
140 | This line leaves the procedure if no message is left (if a null is returned). |
141 | This line returns the ASURXSQL error message to the SYSTSPRT DD. For more information about ASURXSQL error messages, see ASURXSQL-external-function. |
142 | This line ends SQL error processing. |