on 09-12-2011 6:30 PM
Buenas tardes,
Tengo configurado en los socios de negocios un consecutivo ke me va numerando el cliente de acuerdo a su creación, está hecho con una búsqueda formateada que se activa tan pronto cambia el campo de código del SN. Por supuesto cuando dos usuarios abren la creación de clientes y no se ha asignado el ultimo numero de consecutivo, éste los duplica por lo que estoy diseñando el siguiente sp:
IF (@object_type = '2') and @transaction_type in ('A')
begin
Declare @consecutivo as Int
set @consecutivo = (SELECT MAX (U_consecutivo_creac) FROM OCRD)
Declare @consecutivo1 as int
set @consecutivo1 = (select U_consecutivo_creac from OCRD WHERE CardCode = @list_of_cols_val_tab_del)
if @consecutivo1 = @consecutivo
begin
set @error = 18
set @error_message = '*** El consecutivo de este cliente ya existe, por favor vuelva a crear al cliente ***'
end
end
Pero siempre me arroja error aún cuando no sea repetido el consecutivo.
Agradzco la ayuda que me puedan prestar.
intenta con
IF (@object_type = '2') and @transaction_type in ('A')
begin
declare @cuenta as int
Declare @consecutivo1 as int
set @consecutivo1 = (select U_consecutivo_creac from OCRD WHERE CardCode = @list_of_cols_val_tab_del)
set @cuenta= (select count (*) from ocrd where u_consecutivo_creac =@consecutivo1)
if @cuenta>1
begin
set @error = 18
set @error_message = '*** El consecutivo de este cliente ya existe, por favor vuelva a crear al cliente ***'
end
end
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Muchas gracias Mauricio, la respuesta era a que necesitaba. Una lógica diferente. GRACIAS!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hola pruebalo asi
IF @object_type = 2 AND @transaction_type in ('A')
BEGIN
Declare @consecutivo as int
set @consecutivo = (SELECT MAX(U_consecutivo_creac)FROM dbo.OCRD WHERE CardCode=@list_of_cols_val_tab_del)
Declare @consecutivo1 as int
set @consecutivo1 = (select U_consecutivo_creac from dbo.OCRD WHERE CardCode = @list_of_cols_val_tab_del)
if @consecutivo1 = @consecutivo
begin
set @error = 18
set @error_message = '*** El consecutivo de este cliente ya existe, por favor vuelva a crear al cliente ***'
end
end
Saludos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.