> 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.
Chin,
You can either INSERT the record and check for error -239 (duplicate value in
unique index) or UPDATE and check for SQLCA.SQLERRD[2] = 0 (only possible
in V6.0 or greater since you're using SPs - use the dbinfo() function).
If you're using V5.x, then INSERT and check for duplicate is the only way I
can think of. Also it *will* work in any version... :-)
HTH.
--
Ciao,
Billy
+------------------------------------------------------------------------------+
| Billy Wheeler Junior Programmer / Director The West Solutions Group |
+------------------------------------------------------------------------------+
| Oracle isn't the answer. Oracle is the question, and the answer is "no". |
+------------------------------------------------------------------------------+