on 02-05-2014 5:46 PM
set @Duplicado=
(select COUNT(U_Registro) from OCRD T0 group by T0.U_Registro, T0.CardType having T0.U_Registro= @list_of_cols_val_tab_del and T0.cardType='C' )
if @Duplicado >1
begin
select @error =2
select @error_message = 'Número de Registro ya existe'
end
Buenos días,
estoy tratando de modificar el TN pero no me logra validar,
lo que necesito hacer es lo siguiente:
el campo de usuario U_Registro guarda un número único del SN y quiero validar que no coloquen ese número repetido.
Muhas Gracias.
No sé que estoy haciendo mal.
Pasen buen día
En la variable de Lista, lo que viene es el código del cliente. No tu código.
Por lo que el código que necesitas sería como este.
set @Duplicado=
(select COUNT(U_Registro) from OCRD T0
Where T0.U_Registro in (select T1.U_Registro from OCRD T1
Where T1.CardCode = @list_of_cols_val_tab_del and T0.cardType='C')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Gracias Alejandro,
así lo esta haciendo pero se activaba siempre
este es el query original que devuelve si hay duplicados
select COUNT(U_Registro) from OCRD t0 group by t0.U_Registro, T0.CardType having T0.U_Registros='44455' and T0.CardType='C'
Gracias por tu tiempo.
Saludos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
2 opciones te doy.
1. Verifica cual es el contenido de la variable @list_of_cols_val_tab_del hacienda que el mensaje de error que regresa sea el contenido de la variable.
2. En lugar de utilizer el Having, coloca eso en el Where.
select COUNT(U_Registro) from OCRD t0 Where T0.U_Registros='44455' and T0.CardType='C' group by t0.U_Registro, T0.CardType
Buen dia necesito validar, que al crear un SN, el codigo (cardcode) no sea de esta forma 'C-' ,,
el orden que llevamos actualmente es asi C000001, C000002, etc.
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 |
---|---|
98 | |
12 | |
11 | |
6 | |
6 | |
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.