All Forums Database
adtrombley 3 posts Joined 09/12
28 May 2013
Translate loop into Teradata Stored Procedure

How can I translate the following ms sql to Teradat Stored Procedure?
 

DECLARE @logdate DATETIME  

DECLARE @hrinput1 INTEGER

DECLARE @hrinput2 INTEGER

SET @logdate = '2013-03-01' 

SET @hrinput1 = '0'

SET @hrinput2 = '1'

 

while @logdate <= '2013-04-01' 

BEGIN 

--reset parameter values

set @hrinput1 = '0'

set @hrinput2 = '1' 

while 

@hrinput2 <=25

BEGIN 

print @hrinput1

print @hrinput2

 

 

set @hrinput1 = @hrinput1 + 1

set @hrinput2 = @hrinput2 + 1 

END 

print @logdate

set @logdate = DATEADD(day, 1, @logdate) 

END

 

Austin
M.Saeed Khurram 544 posts Joined 09/12
30 May 2013

Hi,
Hope this will work for you!
 
REPLACE PROCEDURE Test()
BEGIN
DECLARE logdate DATE;
DECLARE hrinput1 INTEGER;
DECLARE hrinput2 INTEGER;
SET logdate = '2013-03-01';
SET hrinput1 = '0';
SET hrinput2 = '1';
WHILE logdate <= '2013-04-01'
DO
--reset parameter values
SET hrinput1 = '0';
SET hrinput2 = '1';
WHILE hrinput2 <=25
DO
SET hrinput1 = hrinput1 + 1;
SET hrinput2 = hrinput2 + 1;
END WHILE;
SET logdate =  logdate + INTERVAL '1' DAY;
END WHILE;
END;
CALL Test ();
 
Cheers :)

Khurram

You must sign in to leave a comment.