Re: esql-c update return code
Posted in 1998
Chaiw Kok Kee wrote: > > I would like to update a row in a table and if not found, insert the > record. > > The return value of update (sqlca.sqlcode) returns a 0 when the record > is not found. I thought it should return 100 just like a select > statement. > > Is this a bug? Now I have to do a select first. > > I am using Informix On-line 5.0 This is not a bug but I can see where it is misleading. Mathematically, most set operations are valid on an empty set. The update you executed was on the set rows where (some condition). This set just happens to be empty. So the operation was valid; it just didn't do a blessed thing. You should use the global variable sqlca.sqlerrd[2] after the update. It tells you how many rows were processed in your most recent operation. In this case, it would have been 0, a clear indication that it did nothing. (BTW, in 4gl, it would be sqlca.sqlerrd[3].) HTH -- -- Jake (Never yelled "CROWDED THEATER!" during a fire) +------------------------------------------------------------+ | The expedient performance of a task with excessive concern | | regarding its duration-to-completion engenders a virtual | | certainty of diminished benefit therefrom. | | -- Benjamin Franklin (but he said it in 3 words) | +------------------------------------------------------------+