PowerBuilder · Database exception
What does SQLCode = -1 (Statement Failed) mean in PowerBuilder?
SQLCA.SQLCode returns -1 after any embedded SQL statement or DataWindow database operation fails for a DBMS-specific reason, whether that's a syntax error, constraint violation, connection loss, or driver error. The value -1 itself carries no detail; it only signals that SQLDBCode and SQLErrText must be inspected to learn what actually went wrong.
SQLCA.SQLCode returns -1 after any embedded SQL statement or DataWindow database operation fails for a DBMS-specific reason, whether that's a syntax error, constraint violation, connection loss, or driver error. The value -1 itself carries no detail; it only signals that SQLDBCode and SQLErrText must be inspected to learn what actually went wrong.
Immediately after the failing statement, check SQLCA.SQLCode and, when it equals -1, read SQLCA.SQLDBCode and SQLCA.SQLErrText to get the DBMS-specific code and message rather than acting on SQLCode alone. In DataWindow-driven code, capture the same detail from the dwo/itemname/dberror-style arguments the DBError event supplies.