1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
ALTER PROCEDURE dbo.GetSequence
(
@Tablename varchar(255),
@CurrentValue int OUTPUT
)
AS
--DECLARE @CurrentValue int
BEGIN TRANSACTION LaTransaction
SET @CurrentValue = (SELECT ncurrentvalue FROM Tsequence WHERE ltablename = @Tablename)
SET @CurrentValue = @CurrentValue + 1
UPDATE Tsequence SET ncurrentvalue = @CurrentValue,dmodified = GETDATE() WHERE ltablename = @Tablename
SELECT @CurrentValue
if @@error <> 0
ROLLBACK TRANSACTION LaTransaction
ELSE
COMMIT TRANSACTION LaTransaction
GO |
Partager