cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with FOR loop in Nested BEGIN and END terminals

S0004343680
Explorer
0 Kudos

Hi All,

I am trying to fetch row by row using FOR loop on CURSOR.An i am getting Error attached screen shot:

Below is the logic:

Create Procedure TEST1() LANGUAGE SQLSCRIPT AS

BEGIN

AN01 = Select * from AN.View;

AN02 = SELECT DISTINCT F1,F2,F3 from :AN01 GROUP BY F1,F2,F3;

BEGIN

DECLARE CURSOR ITEM_RULE FOR select F1,F2,F3 from :AN02;

FOR V_ITEM_RULE AS ITEM_RULE DO

SELECT * from TABLE1 where F1 = V_ITEM_RULE.F1;

END FOR;

END;

END;

Here i an getting data from AN01..Then finding the Distinct in AN02.

On AN02 i am applying CURSOR...and for each row i wanted to find an entry in TABLE1 and do a calculation further.

  

-- But when i am using a FOR loop in the Nested BEGIN i am getting below Error.

  

-- I tried to Activate successful without FOR Loop.

  

Any Suggestion on the above issue.

Thanks

kalyan

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member182114
Active Contributor
0 Kudos

Hi Kalyan,

Your procedure is incomplete.

Why are you looping to make a select that you do not use? What is the target for ITEM_RULE_GDS selection?

Also, like it is currently exposed a JOIN is highly recommended.

Are you just playing around with procedure or you really have a scope to do ?

Regards, Fernando Da Rós