on 10-14-2009 10:13 PM
Hola a todos!
El presente es para solicitar apoyo referente a una validación que necesito realizar en el dato maestro de artículo. Voy a utilizar un campo estándar para guardar un código de referencia.
Aqui coloco la validación que he estado realizando:
IF ((@object_type = '4' AND @transaction_type = 'A' )) or ((@object_type = '4' AND @transaction_type = 'U' ))
BEGIN
IF EXISTS
(SELECT T0.ItemCode FROM OITM T0 WHERE (T0.SuppCatNum Is Null) and T0.ItemCode = @list_of_cols_val_tab_del)
BEGIN
SET @error = -4
SET @error_message = 'Falta el Código de referencia'
END
END
Esta validación funciona para cuando el, campo T0.SuppCatNum, está vacio bien sea creando o actualizando el dato maestro de artículo. Pero necesito validar que el código que se está registrando, en dicho campo, no esté creado en la OITM. ¿Cómo puedo realizar esto?
Esperando que puedan brindarme su apoyo.
Saludos cordiales.
Hola Alba:
Corrijo,
Prueba con el siguiente código:
IF ((@object_type = '4' AND @transaction_type = 'A' )) or ((@object_type = '4' AND @transaction_type = 'U' ))
DECLARE @FAB AS NVARCHAR(30)
DECLARE @CONSULTA INT
SET @FAB = (SELECT T0.SuppCatNum FROM OITM T0 WHERE T0.ItemCode = @list_of_cols_val_tab_del)
SET @CONSULTA = (SELECT COUNT(T0.SuppCatNum) FROM OITM T0 WHERE T0.SuppCatNum = @FAB)
BEGIN
IF EXISTS
(SELECT T0.ItemCode FROM OITM T0 WHERE (T0.SuppCatNum Is Null) and T0.ItemCode = @list_of_cols_val_tab_del)
BEGIN
SET @error = -4
SET @error_message = 'Falta el Código de referencia'
END
IF @CONSULTA > '1'
SET @error = -4
SET @error_message = 'Este Código de referencia ya existe'
END
Saludos Cordiales,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hola Alba:
Prueba con el siguiente código:
IF ((@object_type = '4' AND @transaction_type = 'A' )) or ((@object_type = '4' AND @transaction_type = 'U' ))
DECLARE @FAB AS NVARCHAR(30)
DECLARE @CONSULTA INT
SET @FAB = (SELECT T0.SuppCatNum FROM OITM T0 WHERE T0.ItemCode = @list_of_cols_val_tab_del)
SET @CONSULTA = (SELECT COUNT(T0.SuppCatNum) FROM OITM T0 WHERE T0.SuppCatNum = @FAB)
BEGIN
IF EXISTS
(SELECT T0.ItemCode FROM OITM T0 WHERE (T0.SuppCatNum Is Null) and T0.ItemCode = @list_of_cols_val_tab_del)
BEGIN
SET @error = -4
SET @error_message = 'Falta el Código de referencia'
END
IF @CONSULTA > '0'
SET @error = -4
SET @error_message = 'Este Código de referencia ya existe'
END
Saludos Cordiales,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
104 | |
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.