| Upgrade Guides for Genero BDL / 2.21 upgrade guide | |
Unique and primary key constraint violations mostly return error -268, however you might also need to check for error -269 in some instances.
When a unique or primary key constraint is violated, the IBM® Informix® driver returns the error -268 in SQLCA.SQLCODE if the database uses transaction logging, and error -239 if the database uses no logging.
Regarding non-Informix drivers, all 2.21 drivers now return -268 when a unique constraint or primary key constraint is violated. Before 2.21, the Oracle and SQL Server / Sybase drivers returned error -239, which is only returned by IBM Informix databases without transaction logging. Returning error -268 for all drivers is the best choice in a context of transactional databases.
FUNCTION isUniqueConstraintError()
IF (SQLCA.SQLCODE==-239 OR SQLCA.SQLCODE==-268)
OR (SQLCA.SQLCODE==-346 AND SQLCA.SQLERRD[2]==-100)
THEN
RETURN TRUE
ELSE
RETURN FALSE
END IF
END FUNCTION