I'm making a stored proc in teradata v16 that requires me to raise an error. I can see how to make the code to capture an error (see below) but cannot figure out how to raiseerror as you can with other applications. Can some show me how to raise an error?
BEGIN
DECLARE SQL_ERR_CDE INTEGER;
DECLARE SQL_STATE INTEGER;
DECLARE TMPMSG VARCHAR(133);
L1: BEGIN
DECLARE EXIT HANDLER FOR SqlException
BEGIN
SET SQLERRCDE = SqlCode;
SET SQLSTTE = SqlState;
SET SQLMSG = TMPMSG;
SET SQL_ERR_CDE = SqlCode;
SET SQL_STATE = SqlState;
INSERT INTO DW.ERR_STD_PRC_LOG
VALUES ('DW', 'SP_INDEX_STATS' , 'E' , :SQL_ERR_CDE,:SQL_STATE, :TMPMSG, DATE, TIME);
END;
Have you tried ABORT? This should error out the SP call with whatever message you want to include:
ABORT 'Error Message';
Also, take a look at this for how to use SIGNAL: Teradata: How can I raise an error in a stored procedures