Unique Indexes
Posted in 1993
I have a table in which there's a unique index created, and it involves 9 columns. I'm having a problem when I goto $select from it in one of my *.ec files. The sqlca.sqlcode returned is 100 (SQLNOTFOUND). When I looked it up in the ESQL manual, the ISAM error reads: "there is already a record with the same value in a unique key." and the Corrective Action specified: "Check that you did not attempt to add a duplicate value to a column with a unique index by way of iswrite, isrewrite, isrewcurr, or isaddindex." I'm puzzled because all I'm trying to do is to select a row out of this table, in which I've granted permission to select, update, insert, delete, and index on. Here's what I did: $select col10, col11, col12, col13, col14, col15, col16 into $col10, $col11, $col12, $col13, $col14, $col15, $col16 from tablename where col1 = $ptr->col1 and col2 = $ptr->col2 and col3 = $ptr->col3 and col4 = $ptr->col4 and col5 = $ptr->col5 and col6 = $ptr->col6 and col7 = $ptr->col7 and col8 = $ptr->col8 and col9 = $ptr->col9; The 'unique' index key includes col1 - col9. I don't understand why prior to putting in this 'select' statement in my routine, I had an $update statement to the same table based on the same set of columns, and I didn't get this SQLNOTFOUND returned. I tried to debug this through softbench and was able to look at all the fields prior to calling the ESQL routine and after, but softbench skips over the ESQL stuff. So prior to calling this routine, I went into isql and was able to verify that the row exists in the table that matches the select where clause. Any insights would help me out greatly. Thanks.