How to get existing record on a unique key violation

Jens Schauder picture Jens Schauder · Jan 24, 2013 · Viewed 7.1k times · Source

when performing an insert I get the following error message

AN INSERTED OR UPDATED VALUE IS INVALID BECAUSE INDEX IN INDEX SPACE xxxxx CONSTRAINS 
COLUMNS OF THE TABLE SO NO TWO ROWS CAN CONTAIN DUPLICATE VALUES IN THOSE COLUMNS. 
RID OF EXISTING ROW IS X'0000000A20'.. SQLCODE=-803, SQLSTATE=23505, DRIVER=3.53.95

How can I do a select to get the row that already exists in the database?

Platform is z/OS; SELECT GETVARIABLE('SYSIBM.VERSION') FROM SYSIBM.SYSDUMMY1 returns DSN09015 so I guess thats Version 9

Answer

woita picture woita · May 29, 2013

X'0000000A20' is Hexadecimal format. You can translate it with Windows calc.

A20 = 2592

So you can do SELECT * FROM table_name where RID(table_name) = 2592 and you will get what you need