Teradata's single and multiple Exception Handlers are replaced by its equivalent handlers in Snowflake Scripting.
DECLARE < handler_type > HANDLER
FOR < condition_value_list > < handler_action > ;
CREATE PROCEDURE handlerSample ()
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION
INSERT INTO Proc_Error_Table ('procSample', 'Failed SqlException');
SELECT * FROM Proc_Error_Table;
END;
CREATE PROCEDURE handlerSample ()
BEGIN
DECLARE ConditionByUser1 CONDITION;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
INSERT INTO Proc_Error_Table ('procSample', 'Failed SqlException');
DECLARE EXIT HANDLER FOR ConditionByUser1
INSERT INTO Proc_Error_Table ('procSample', 'Failed ConditionByUser1');
SELECT * FROM Proc_Error_Table;
END;
CREATE OR REPLACE PROCEDURE handlerSample ()
RETURNS VARCHAR
LANGUAGE SQL
COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"teradata"}}'
EXECUTE AS CALLER
AS
$$
BEGIN
SELECT
* FROM
Proc_Error_Table;
EXCEPTION
WHEN other THEN
INSERT INTO Proc_Error_Table
VALUES ('procSample', 'Failed SqlException');
END;
$$;
CREATE OR REPLACE PROCEDURE handlerSample ()
RETURNS VARCHAR
LANGUAGE SQL
COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"teradata"}}'
EXECUTE AS CALLER
AS
$$
DECLARE
ConditionByUser1 EXCEPTION;
BEGIN
SELECT
* FROM
Proc_Error_Table;
EXCEPTION
WHEN ConditionByUser1 THEN
INSERT INTO Proc_Error_Table
VALUES ('procSample', 'Failed ConditionByUser1');
WHEN other THEN
INSERT INTO Proc_Error_Table
VALUES ('procSample', 'Failed SqlException');
END;
$$;