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

Home -> Community -> Usenet -> c.d.o.server -> Re: Is this safe???

Re: Is this safe???

From: David Sisk <davesisk_at_ipass.net>
Date: Sun, 26 Sep 1999 20:57:48 -0400
Message-ID: <Z4zH3.263$A3.459@news.ipass.net>


Hi:

Why don't you just use a sequence, then you won't have to worry about it?

Best regards,

--
David C. Sisk
Need tech info on Oracle? Visit The Unofficial ORACLE on NT site at http://www.ipass.net/~davesisk/oont.htm Like original modern rock? Listen to song samples and buy a CD at http://www.mp3.com/disparityofcult
Raleigh music compilation! All $$$ go to NC Food Bank. http://www.mp3.com/whisper2ascream

Chris Forlano wrote in message <37EE9774.AF71ECD8_at_nortelnetworks.com>...
>Does the following procedure guarantee atomicity for the id_generator
>table?
>What I mean to say is, how can I guarantee that no one else will be able
>to
>update the id_generator table at the same time this function is running?
>
>If not, how can I guarantee it?
>Can I do this as a function?
>
>create or replace
>PROCEDURE generate_id( type_in in varchar2, id_out out varchar2 )
>AS
> CURSOR id_cursor IS
> SELECT prefix, next_id FROM id_generator WHERE type = type_in;
> prefix varchar2(20);
> next_id number(9);
>BEGIN
>
> OPEN id_cursor;
>
> /* Get the next available id. */
> FETCH id_cursor INTO prefix, next_id;
>
> /* Update to the next available id. */
> UPDATE id_generator SET next_id = next_id + 1 WHERE type = type_in;
>
> /* Create an id containing a prefix and id (ex, TST000123). */
> id_out := CONCAT( prefix, LPAD( TO_CHAR( next_id ), 9, '0' ) );
>
> CLOSE id_cursor;
>
>END generate_id;
>
>I'm running Oracle 8.0.5 on Solaris 2.6.
>
>Thanks,
>
>Chris
>
>--
>Chris Forlano
>Automation Development
>Nortel Networks, Maidenhead
>590 4342 (01628 434 342)
>cforlano_at_nortelnetworks.com
>
>
Received on Sun Sep 26 1999 - 19:57:48 CDT

Original text of this message

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