|
|
sybperl-l Archive
Up Prev Next
From: "Ramprasad Joshi" <ramprasad dot joshi at csfb dot com>
Subject: Re: next key table
Date: Sep 19 1997 9:52AM
Hi,
Insert should be inside the transaction to ensure that there are no
gaps. If gaps in key number sequence are OK (they will still be in increasing
order), then the insert can be outside the transaction.
Regards,
Ramprasad
On Sep 19, 2:43, Doug Fairclough wrote:
> Subject: next key table
>
> http://www.sybase.com/products/whitepapers/pkey_wpaper.html
>
> states that :
>
> begin tran
>
> declare @next_key
> update next_key set next_key = next_key + 1
> select @next_key = next_key + 1 from next_key
>
> insert into data_table (key_column, ...) values (@next_key, ...)
>
> commit tran
>
> does anyone know if its necessary to have the 'insert' statement
> _within_ the transaction in order to gaurantee uniqueness in the
> keys generated ?
>
> i have code that does the above, but i dont have my insert statements
> within 'begin tran' and 'commit tran' but after it.
>
> thanks !
>
> doug
>
>-- End of excerpt from Doug Fairclough
|