Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sequence procedure
Message
From
18/08/2017 15:56:22
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Sequence procedure
Miscellaneous
Thread ID:
01653485
Message ID:
01653485
Views:
49
hi, I have the following procedure in sql server 2008 to get the unique sequence of each type of transaction
ALTER PROCEDURE [dbo].[P_SECUENCIAS]@movi char(4),@crear bit
AS
BEGIN
	Set Nocount On
	Declare @Ret INT,@cTabla Varchar(255),@nuevoid int,@secuencia int 
	set @secuencia=0
	if @crear=1
	begin
		-- Verificar si existe la tabla
		IF Exists(SELECT tipomoviid FROM secuencias WHERE tipomoviid=@movi) 
			BEGIN -- Si ya existe, se obtiene el valor generado
				UPDATE secuencias set @nuevoid=secuenciaid+1,secuenciaid=@nuevoid WHERE tipomoviid=@movi
			END
		ELSE
			BEGIN -- Si no existe, se genera la nueva tabla
				SELECT @NuevoId = 1
				INSERT secuencias (secuenciaid,tipomoviid) VALUES (@NuevoId,@movi)
			END 
	end
	else
	begin
		set @nuevoid=isnull((select secuenciaid from secuencias WHERE tipomoviid=@movi),0)
	end
	select @nuevoid as secu
END
I do not know what's happening because I'm being repeated many transactions and I'm not supposed to be doing
Jose Manuel Ramirez
Reply
Map
View

Click here to load this message in the networking platform