I have a simple stored procedure that reads from a table and inserts into another table. Stored procedure is given below

CREATE PROCEDURE TEST_PROC
()
SPECIFIC TEST_PROC
MODIFIES SQL DATA
NOT DETERMINISTIC
CALLED ON NULL INPUT
COMMIT ON RETURN NO
INHERIT SPECIAL REGISTERS
OLD SAVEPOINT LEVEL
LANGUAGE SQL
P1: BEGIN

FOR i AS SELECT COLUMN1, COLUMN2
FROM TEST_TABLE
DO
INSERT INTO TEST_MSG(MSG) VALUES (i.COLUMN1);
END FOR;


END P1;


When I execute this proc as follows:
CALL TEST_PROC()

I see the following error:
An exception occurred
Message: [IBM][CLI Driver] CLI0115E Invalid cursor state. SQLSTATE=24000
SQL: CALL TEST_PROC()
Method: TDB2DirQuery.Next


I am unable to figure out what's causing invalid cursor state.
Can anyone point out the mistake that I'm doing in this proc?
I tried by definining a cursor and looping through it, but was getting the same error.
Thanks in advance.