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
MODIFIES SQL DATA
CALLED ON NULL INPUT
COMMIT ON RETURN NO
INHERIT SPECIAL REGISTERS
OLD SAVEPOINT LEVEL
FOR i AS SELECT COLUMN1, COLUMN2
INSERT INTO TEST_MSG(MSG) VALUES (i.COLUMN1);
When I execute this proc as follows:
I see the following error:
An exception occurred
Message: [IBM][CLI Driver] CLI0115E Invalid cursor state. SQLSTATE=24000
SQL: CALL TEST_PROC()
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.