Stored Procedure

Analytics
Enthusiast

Stored Procedure

I am new to Teradata. I need to create a procedure which has to select and insert values based on a If Condition. While creating this procedure it is throwing me syntax error. Can any one help me with this.

Create Procedure Test_Run_Ins(IN T1 Integer, IN T2 Integer)
Begin

Declare cnt Integer;
Declare i Integer;

Select Max(ABC)+1 into :cnt
From Test;

If i <= cnt

Then

Insert into TEST_RUN
(
A,
B,
C
)
Select
:cnt,
123,
456
From TestX
Where BC between :T1 and :T2;

End if ;
End
1 REPLY
Enthusiast

Re: Stored Procedure

Hi,
You have to Initialize the value of I
by:
set i=0; //the value you want

Also check the column BC exists in your table in your condition:
" Where BC between :T1 and :T2"

Regds,
sachin