Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

CREATE PROCEDURE SBO_SP_TransactionNotification

(
in object_type nvarchar(200), -- SBO Object Type
in transaction_type nchar(1), -- [A]dd, [U]pdate, [D]elete,
[C]ancel, C[L]ose
in num_of_cols_in_key int,
in list_of_key_cols_tab_del nvarchar(255),
in list_of_cols_val_tab_del nvarchar(255)
)
LANGUAGE SQLSCRIPT
AS
-- Return values
error int; -- Result (0 for no error)
error_message nvarchar (200); -- Error string to be displayed

BEGIN
DECLARE activo smallint;
DECLARE MYCOND CONDITION;
DECLARE EXIT HANDLER FOR MYCOND BEGIN END;

error := 0;
error_message := N'Ok';

activo := 1 ;

/*CALL "MSS_ValGeneral"
(:object_type, :transaction_type, :num_of_cols_in_key, :list_of_key_cols_tab_del, :
list_of_cols_val_tab_del, :error , :error_message);

IF :activo = 1 THEN
CALL
STR_TN_General(right(:object_type,20),:transaction_type,:list_of_cols_val_tab_del,:
error, :error_message);
IF :error<>0 THEN
select :error, :error_message FROM dummy;
SIGNAL MYCOND;
END IF;
END IF;

CALL
SOPH_SP_TRANS_VA(:object_type,:transaction_type,:list_of_cols_val_tab_del,:error, :
error_message);
IF :error<>0 THEN
select :error, :error_message FROM dummy;
SIGNAL MYCOND;
END IF;
*/

-- CALL
"SOPH_SP_TRANS_VA"(:object_type,:transaction_type,:list_of_cols_val_tab_del,:error,
:error_message);
---validaciones SOPHOS
IF IFNULL(:error,0)=0 THEN
CALL
SOPH_SP_TRANS_VA(:object_type,:transaction_type,:list_of_cols_val_tab_del,:error, :
error_message);
/*select :error, :error_message FROM dummy;
SIGNAL MYCOND;*/
END IF;
---validaciones cayman
IF IFNULL(:error,0)=0 THEN
CALL "MSS_ValGeneral"
(:object_type, :transaction_type, :num_of_cols_in_key, :list_of_key_cols_tab_del, :
list_of_cols_val_tab_del, :error , :error_message);
END IF;
--FIN
IF IFNULL(:error,0) =0 THEN
error :=0;
error_message:= N'Ok';
END IF;

IF :activo = 1 and IFNULL(:error,0) =0 THEN


CALL
STR_TN_General(right(:object_type,20),:transaction_type,:list_of_cols_val_tab_del,:
error, :error_message);
/* IF :error<>0 THEN
select :error, :error_message FROM dummy;
SIGNAL MYCOND;
END IF;*/
END IF;

--FIN

------ Validacion de numero de folio -------------


--FACTURA VENTA
IF ifnull(:error,0)=0 and :object_type = '13' and (:transaction_type = 'A'
OR :transaction_type = 'U')
THEN

UPDATE OINV SET "FolioNum" = 0


WHERE "DocEntry" = :list_of_cols_val_tab_del;
END IF;

--NOTA CREDITO VENTA


IF ifnull(:error,0)=0 and :object_type = '14' and (:transaction_type = 'A'
OR :transaction_type = 'U')
THEN
UPDATE ORIN SET "FolioNum" = 0
WHERE "DocEntry" = :list_of_cols_val_tab_del;

END IF;
--GUIA DE REMISION VENTA
IF ifnull(:error,0)=0 and :Object_type = '15' and (:transaction_type = 'A'
OR :transaction_type = 'U')
THEN
UPDATE ODLN SET "FolioNum" = 0
WHERE "DocEntry" = :list_of_cols_val_tab_del;

END IF;
------ Validacion de numero de folio -------------
IF IFNULL(:error,0) =0 THEN
error :=0;
error_message:= N'Ok';
END IF;

-- Select the return values


select :error, :error_message FROM dummy;

END;

You might also like