ABS Tech Note: DAL29 UPDATE Statements and $sqlcode

When a DAL UPDATE statement is executed and does not modify any rows, $sqlcode returns 0, even though some kind of error response would be appropriate.
The issue is that DAL is using dynamic SQL statements, and DBMS vendors do not return an appropriate SQLCODE to DAL under this circumstance, so there is no way for DAL to return an error.

If this information is necessary, you can check for a non-zero set of data by doing a SELECT FOR EXTRACT and checking $rowcnt to make sure it is greater than zero.

For instance, the following SQL will update no rows in the demonstration tables, but return an $sqlcode of 0:

UPDATE offices SET city = 'Port Ludlow' WHERE office_nr = 444;
print $sqlcode;

To verify whether or not this command modifies rows, the following code can be used:

SELECT city FROM offices WHERE office_nr = 444 FOR EXTRACT;
print $rowcnt;

If $rowcnt is greater than zero, then the equivalent UPDATE statement will modify rows.

This limitation may be resolved in a future release of DAL if the appropriate information is available from the host DBMS.
Published Date: Feb 19, 2012