Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> REPOST: Re: To find a just-inserted record

REPOST: Re: To find a just-inserted record

From: Ed prochak <ed.prochak_at_alltel.com>
Date: 26 Dec 2001 11:01:59 -0800
Message-ID: <6$--$$_--%-$$_%%$$@news.noc.cabal.int>


S P Arif Sahari Wibowo <arifsaha_at_yahoo.com> wrote in message news:<Pine.LNX.4.42.0112211242460.28418-100000_at_macbeth.tirone.com>...
> Replying Steve, Ed prochak:
>
> On Fri, 21 Dec 2001, Steve wrote:
> >insert into MY_TABLE values (..................) returning rowid into
> >MY_ROWID_VARIABLE
>
> Hey, great! This is what I am looking for. Somehow I missed it earlier.
> Thanks.
>
> On 21 Dec 2001, Ed prochak wrote:
> >here's a hint: think PRIMARY KEY.
>
> This solution have some diffculties:
>
> - It require the table to have unique non null primary key. Not all table
> have primary key.

(NOTE: by definition a primary key is non-null and unique, so the adjetives above are a little overkill).

If you use the rowid for anything beyond modifying the row just inserted, you are headed into dangerous territory (think about backup and restore).
Having tables without primary keys are dangerous in a different way.

>
> - It require either the primary key is in predictable sequence, or the
> primary key to be generated before insert, which not always easy to do.

If the key is an ORACLE sequence, then get the current value. It doesn't have to be generated before the insert. You might have to get the value before the insert if you use something like a timestamp as the primary key or part of the key.
>
> Thanks, though.

You're welcome.

 Again keep in mind my comments refer to the use beyond the immediate insert.
(I suspect you understand this but other ORACLE beginners may not.)

Good luck,
  Ed

This message was cancelled from within Mozilla. Received on Wed Dec 26 2001 - 13:01:59 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US