Subject Re: [ib-support] using Gen_id from a stored proc
Author Helen Borrie
At 01:56 PM 24-03-01 -0300, you wrote:

>(snip)
> >
> >btw, don't write a procedure that performs its own increment on Gen_ID(GeneratorName,0) as suggested by somebody. This is unsafe and totally defeats the point
> >of using a generator which is (a) to ensure that PK values are unique and (b) to keep the appointment of numbers for primary key assignments outside transaction
> >control.
>
>Curious... You and AnnH seems to disagree strongly in this question. The thing that make it funny is that you both use
>quite similar arguments to justify it.

Ann H and I disagree? Never!

I think you have missed the point, Fabrice.

This is a healthy use of a stored proc to get a unique identifier:

CREATE PROCEDURE GET_NEXT_ID
RETURNS (NEXT_ID NUMERIC(18,0))
AS
BEGIN
NEXT_ID = GEN_ID(THE_GENERATOR, 1); /* NEXT_ID is fresh and unique */
SUSPEND;
END

This is a treacherous use:

CREATE PROCEDURE GET_NEXT_ID
RETURNS (NEXT_ID NUMERIC(18,0))
AS
BEGIN
NEXT_ID = GEN_ID(THE_GENERATOR, 0); /* This number was generated for a different row */
NEXT_ID = NEXT_ID + 1; /* Recipe for key violations, Generator principle defeated */
SUSPEND;
END

>That's why I love mailing lists. :-)

One of the deficiencies of mailing lists is that confusion reigns supreme when one person misreads something. :))

Regards,
Helen


> >
> >Cheers,
> >Helen
> >
> >All for Open and Open for All
> >InterBase Developer Initiative · http://www.interbase2000.org
> >_______________________________________________________
> >
> >
> >To unsubscribe from this group, send an email to:
> >ib-support-unsubscribe@egroups.com
> >
> >
> >
> >Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
> >
> >
>
>
>[]s Fabricio
>Systems Developer
>
>
>
>
>To unsubscribe from this group, send an email to:
>ib-support-unsubscribe@egroups.com
>
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

All for Open and Open for All
InterBase Developer Initiative · http://www.interbase2000.org
_______________________________________________________