PowerBuilder · Database exception
What does SQLDBCode 2627 (SQL Server Unique Constraint Violation) mean in PowerBuilder?
SQLCA.SQLDBCode returns 2627, SQL Server's native error for a unique index/key violation, when a DataWindow or DataStore Update() attempts to insert a row whose key value already exists. On some driver/DataStore combinations SQLCode itself comes back -1 with SQLCode/SQLErrText left blank, so the 2627 has to be captured from the DBError event of a datastore-derived object instead.
SQLCA.SQLDBCode returns 2627, SQL Server's native error for a unique index/key violation, when a DataWindow or DataStore Update() attempts to insert a row whose key value already exists. On some driver/DataStore combinations SQLCode itself comes back -1 with SQLCode/SQLErrText left blank, so the 2627 has to be captured from the DBError event of a datastore-derived object instead.
Inherit a custom DataStore/DataWindowChild object that overrides the dberror event to capture sqldbcode and sqlerrtext directly, since the default SQLCA properties can come back empty on some driver paths for this error. Use the 2627 to drive duplicate-key-specific recovery (merge/update instead of insert) rather than a generic failure message.