Up Prev Next
From: "Ramprasad Joshi" <ramprasad dot joshi at csfb dot com>
Subject: Re: next key table
Date: Sep 19 1997 9:52AM
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.
On Sep 19, 2:43, Doug Fairclough wrote:
> Subject: next key table
> 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 !
>-- End of excerpt from Doug Fairclough