Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: updating current row of cursor resultset in OCI
joeyee1_at_msn.com (Joe) writes:
> I'm using Oracle9i and converting some existing applications from
> Sybase, which allows for update of current row in the result set with
> its ct_cursor function call. I've looked through the Oracle
> documentation, the news groups in Google and asktom.oracle.com and
> haven't found an example in OCI of how to do something like this:
>
> Some sample C code that uses OCI to create a cursors using the "OPEN
> C1 FOR SELECT ... FOR UPDATE", and later uses the cursor (C1) to
> update the row via the "UPDATE ... SET .... WHERE CURRENT OF C1"
> statement.
>
> I saw that this question was posed before on many occasions, and there
> were basically 2 types of response (1) No response (2) Use rowid as
> part of the "SELECT ... FOR UPDATE". This second option, although
> seems to work, also appears to be a hack. It looks like a hack because
> (a) I saw a bunch of postings and in asktom.oracle.com that the rowid
> may change depending on the type of data changes (b) updating current
> row of cursor result set is supposed to be in the SQL standard and I
> can do it in PL/SQL, why do I need to play around with rowid, which is
> an internal feature of the Oracle database.
From the concept manual (a96524):
"Because rowids are constant for the lifetime of a row piece, it is useful to reference rowids in SQL statements such as SELECT, UPDATE, and DELETE."
So the second method is safe.
Harald Received on Mon Sep 08 2003 - 11:24:46 CDT