I have a stored procedure (below), that is suppose
to get a Reg Number from a table, (Reg_Number), in
such a way that every time the stored procedure is called,
it will get a different reg number, even if the stored
procedure is called simultaneously from two different
places,
However it is not working that way.
If two different users access a function in there
VB program at the same time, the two different users
will get the same reg number.
I have looked at the stored procedure, it looks foolproof,
yet it is not working that way.
Thanks in Advance,
Laurence Nuttall
Programmer Analyst III
UCLA - Division of Continuing Education
'---------------------------------------------------------------------------
Here it is:
CREATE PROCEDURE sp_GetNextRegNu m
@newRegNum char(6) = NULL OUTPUT
AS
LABEL_GET_ANOTH ER_REG:
Select @newRegNum =(select min(Reg) from reg_number)
IF Exists (select Reg from reg_number where reg = @newRegNum )
Begin
Delete from reg_number where reg = @newRegNum
IF @@Error <> 0
Begin
Goto LABEL_GET_ANOTH ER_REG
End
--Endif
End
ELSE
GoTo LABEL_GET_ANOTH ER_REG
--Endif
GO
to get a Reg Number from a table, (Reg_Number), in
such a way that every time the stored procedure is called,
it will get a different reg number, even if the stored
procedure is called simultaneously from two different
places,
However it is not working that way.
If two different users access a function in there
VB program at the same time, the two different users
will get the same reg number.
I have looked at the stored procedure, it looks foolproof,
yet it is not working that way.
Thanks in Advance,
Laurence Nuttall
Programmer Analyst III
UCLA - Division of Continuing Education
'---------------------------------------------------------------------------
Here it is:
CREATE PROCEDURE sp_GetNextRegNu m
@newRegNum char(6) = NULL OUTPUT
AS
LABEL_GET_ANOTH ER_REG:
Select @newRegNum =(select min(Reg) from reg_number)
IF Exists (select Reg from reg_number where reg = @newRegNum )
Begin
Delete from reg_number where reg = @newRegNum
IF @@Error <> 0
Begin
Goto LABEL_GET_ANOTH ER_REG
End
--Endif
End
ELSE
GoTo LABEL_GET_ANOTH ER_REG
--Endif
GO
Comment