Below i am producing a series of steps that creates a stored procedure. The stored procedure behaves like a sequence in oracle.
The code below creates the table by name 'sequences'. This table will be used to hold the next value that can be used for a particular sequence
The following code creates the stored procedure that gets the next value from the specified sequence in the 'sequences' table.
Now my question is that if this procedure is run on the same database instance by multiple users simultaneously, will the procedure be 'synchronized' (that is will it run to completion for a user before starting to run for another one)?
kind regards,
ghd
The code below creates the table by name 'sequences'. This table will be used to hold the next value that can be used for a particular sequence
Code:
CREATE TABLE sequences ( seq varchar(100) primary key, sequence_id int );
Code:
CREATE PROCEDURE nextval @sequence varchar(100), @sequence_id INT OUTPUT AS -- return an error if sequence does not exist -- so we will know if someone truncates the table set @sequence_id = -1 UPDATE sequences SET @sequence_id = sequence_id = sequence_id + 1 WHERE seq = @sequence RETURN @sequence_id
kind regards,
ghd
Comment