on 02-06-2014 4:05 PM
Buenos días,
estoy haciendo un conjunto de validaciones, las cuales se activan correctamente, pero me muestra para todas las validaciones el ultimo mensaje declarado, que estaré colocando mal??
if (@object_type = '2' and @transaction_type in ('A','U'))
set @Cod_SN = @list_of_cols_val_tab_del
Begin
Begin -- Valida al crear SN que campo de usuario REFERENCIA no se encuentre vacío
if (select COUNT(*) from OCRD t0 where t0.cardcode= @Cod_SN and t0.U_REF is null )>0
select @error =1
select @error_message = 'Campo -REFERENCIA esta vacio'
End
--------------------------------------------------------------------------------------------------------------------
Begin -- Valida al crear SN que campo de usuario REFERENCIA no este duplicado
set @Duplicado= (select COUNT(U_REF) from OCRD T0
Where T0.U_REF in (select T1.U_REF from OCRD T1
Where T1.CardCode = @Cod_SN and T0.cardType='C'))
if @Duplicado >1
select @error =2
select @error_message = 'Número de -REFERNCIA - ya existe'
End
--------------------------------------------------------------------------------------------------------------------
Begin-- Valida al crear SN que campo de usuario Personeria no se encuentre sin elegir
if (select COUNT(*) from OCRD t0 where t0.cardcode= @Cod_SN and t0.U_PERSONERIA is null )>0
select @error =3
select @error_message = 'Campo -PERSONERIA- esta vacio'
End
end
--------------------------------------------------------------------------------------------------------------------------------
-- Select the return values
select @error, @error_message
end
La linea de Set esta mal ubicada. Debe estar debajo del begin.
Asi como lo tienes el IF es una sola linea.
Tambien tus if, les falta el begin, pero debajo del If, no antes.
Si haces esto
If A <= 0
Print A
Print B
El resultado si A es mayor a cero va a ser "B"
Pero si haces
If A <= 0
Begin
Print A
Print B
End
El resultado si A es mayor a cero no va a devolver nada.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Gracias
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Cada caso es exluyente y es un error independiente que puede afectar en el maestro de Socios de Negocios.
Gracias.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Los errores son excluyentes o pueden ocurrir todos al mismo tiempo?
En ese ultimo caso cual deberías desplegar?
En el ejemplo que estas ejecutando muestra el ultimo error declarado, eso es porque ese error ocurre realmente o lo muestra incluso si no pasa?
Quizás es solo que siempre pasa al final por el último error declarado y por eso es que te lo muestra.
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 |
---|---|
91 | |
11 | |
10 | |
6 | |
5 | |
5 | |
5 | |
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.