views:

3

answers:

1

Hi,

I wrote a very simple script. I am new to PSQL and I wanted to return some values based on a very simple loop.

CREATE PROCEDURE DRAW_DOWN
RETURNS(
I_VAL INTEGER)
AS
DECLARE VARIABLE STARTING_BALANCE INTEGER;
DECLARE VARIABLE TRADING_SERIES INTEGER;
DECLARE VARIABLE I INTEGER;
BEGIN

SUSPEND;
I_VAL = 1;

WHILE (i < 5) DO
BEGIN

/*RAND();*/
SUSPEND;
I_VAL = i;
i = i +1;   
END  
SUSPEND; 
END;

This just returns one value.

What am i doing wrong?

Regards, Tom

A: 

You're probably running the proc with EXECUTE instead of SELECT. You'd use

SELECT *
FROM DRAW_DOWN

...for multiple results.

Craig Stuntz