on 01-12-2010 4:32 PM
Estimados amigos:
Tengo un campo de usuario llamado Orden de Compra, quisiera hacer una validacion o en todo caso que podria emplear para que el numero que ingresen no se duplique siempre y cuando la Orden de Venta este en estado abierto
Espero me puedan ayudar a como hacer esta validacion.
Slds
QASAC
Prueba esta opcion con el status abierto
IF ((@object_type = '17' AND @transaction_type = 'A' )) or ((@object_type = '17' AND @transaction_type = 'U' ))
begin
DECLARE @REF AS NVARCHAR(10)
DECLARE @existe INT
SET @REF = (SELECT U_userfield FROM ORDR WHERE DocNum = @list_of_cols_val_tab_del)
SET @existe = (SELECT COUNT(U_userfield) FROM ORDR WHERE DocStatus='O' and U_userfield = @REF)
end
IF @existe >1
begin
SET @error = -1
SET @error_message = 'Esta referencia existe en otra orden abierta'
END
saludos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hola Jesus...
Revisa el siguiente post..., plantea un caso de validación para datos repetidos
A partir de lo que entiendo sería mas o menos así..., donde U_nnn sería el campo de usuario
IF ((@object_type = '17' AND @transaction_type = 'A' )) or ((@object_type = '17' AND @transaction_type = 'U' ))
DECLARE @FAB AS NVARCHAR(30)
DECLARE @CONSULTA INT
SET @FAB = (SELECT T0.U_nnn FROM ORDR T0 WHERE T0.DocNum = @list_of_cols_val_tab_del)
SET @CONSULTA = (SELECT COUNT(T0.U_nnn) FROM ORDR T0 WHERE T0.U_nnn = @FAB)
BEGIN
IF EXISTS
(SELECT T0.DocNum FROM ORDR T0 WHERE (T0.U_nnn Is Null) and T0.DocNum = @list_of_cols_val_tab_del)
BEGIN
SET @error = -4
SET @error_message = 'Falta el nnn'
END
IF @CONSULTA > '1'
SET @error = -4
SET @error_message = 'Este Campo de usuario no puede ser duplicado'
END
Espero te sea de ayuda,
Saludos Cordiales,
Edited by: Paul Ponce on Jan 12, 2010 5:42 PM
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.