Re: Help: update record if existed, else insert it
Posted in 1996
Check the sqlca record via dbinfo for the number of rows affected by your update. If it's 0 do the insert. This is not an exception, just a simple call to dbinfo inside the main part of your SPL code. Using dbinfo of course assumes you are on version 6.0 or later of the engine. If not there are some workarrounds described in the FAQ at www.iiug.org c811052@bsdpc1.iii.org.tw (Chih-Cherng Chin) wrote: :Hi all, :Being new to SPL, and wanting to implement a SP to log hits, I'm having :problems writing it. I want to do the following: :1. if the corresponding record exists, update its column, :2. if not, insert a new record. :Originally, I thought about doing it this way: :1. Try to update the record, whether it exists or not, :2. if the update failed, use the exception to insert a new record. :But it turns out that the failed update is not considered as a :error, so I can't do that. I think there are many problems similar :to this, so please share your experience. Thanks in advance. :Chih-Cherng Chin :elmo@iii.org.tw Nils.Myklebust@idg.no NM Data AS, P.O.Box 9090 Gronland, N-0133 Oslo, Norway My opinions are those of my company The Informix FAQ is at http://www.iiug.org