Conditional Statements in Teradata

Database
SAP
Enthusiast

Conditional Statements in Teradata

Hi ,

Is there any statement relevant to GOTO in stored procedure language ?

My Scenario is :-

Insert ....Select .....;

IF SQLCODE < 0 THEN GOTO EROR_HANDLER;

END IF;

EROR_HANDLER: BEGIN

my errortable is updated here with .

END

;

Basically , i want error table to updated with errorcode if any of my DML faces any error . I need to jump into a new label which i have set already . Please suggest with jumping options :P . ITERATE works only with LOOPS .

Thanks in Advance !!!

2 REPLIES
Enthusiast

Re: Conditional Statements in Teradata

You can think of calling a stored proc from another one. In the called one you can put your if else condition. example

CREATE PROCEDURE Sp2(INOUT p1 INTEGER)

BEGIN

IF (.....) THEN

CALL Sp1(p1- 1);

END IF;

END;

SAP
Enthusiast

Re: Conditional Statements in Teradata

Thats a brilliant Idea Raja !!!! Thanks !!! I would put all my error handlers in one stored proc and call it wherever required .:) :)