Check the prepared statement

When PREPARE sends the statement string to the database server, the database server parses it to analyze it for errors. The database server indicates the success of the parse in the sqlca structure, as follows:
  • If the syntax is correct, the database server sets the following sqlca fields:
    • The sqlca.sqlcode field (SQLCODE) contains zero.
    • The sqlca.sqlerrd[0] field contains an estimate of the number of rows affected if the parsed statement was a SELECT, UPDATE, INSERT, or DELETE.
    • The sqlca.sqlerrd[3] field contains an estimated cost of execution if the parsed statement was a SELECT, UPDATE, INSERT, or DELETE. This execution cost is a weighted sum of disk accesses and total number of rows processed.
  • If the statement string contains a syntax error, or if some other error was encountered during the PREPARE, the database server sets the following sqlca fields:
    • The sqlca.sqlcode field (SQLCODE) is set to a negative number (<0). The database server also sets the SQLSTATE variable to an error code.
    • The sqlca.sqlerrd[4] field contains the offset into the statement text where the error was detected.