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$--$$_--%-$$_%%$$_at_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

  • WAS CANCELLED BY =======: Path: news.sol.net!spool0-nwblwi.newsops.execpc.com!newsfeeds.sol.net!newsengine.sol.net!hammer.uoregon.edu!canoe.uoregon.edu!logbridge.uoregon.edu!newsfeed.berkeley.edu!ucberkeley!sjc1.nntp.concentric.net!newsfeed.concentric.net!newsfeed.ozemail.com.au!ozemail.com.au!not-for-mail Message-ID: <cancel.e51b160.0112261101.61cedd1e_at_posting.google.com> Control: cancel <e51b160.0112261101.61cedd1e_at_posting.google.com> Subject: cmsg cancel <e51b160.0112261101.61cedd1e_at_posting.google.com> From: ed.prochak_at_alltel.com (Ed prochak) Newsgroups: comp.databases.oracle.misc X-No-Archive: yes Lines: 2 NNTP-Posting-Host: wonenara.ozemail.com.au X-Trace: ozemail.com.au 1009694992 203.108.164.177 (Sun, 30 Dec 2001 17:49:52 EST) NNTP-Posting-Date: Sun, 30 Dec 2001 17:49:52 EST Organization: OzEmail Ltd, Australia Distribution: world Date: Sun, 30 Dec 2001 04:09:52 GMT

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

Original text of this message