Quantcast
Channel: SQL Cursors – IT Answers
Viewing all articles
Browse latest Browse all 16

SQLRPGLE Cursors and Recursion

$
0
0

I’m trying to recursively call a PI in my SQLRPGLE program.

Problem is, I get an SQLCODE error of -519 and I’m sure it has to do with cursors and the prepare statement in my PI.

Here’s the code:

pprintPrograms    b
     dprintPrograms    PI
     d program                       10a   value
     d spacer                        10a   value
     d
     C/FREE
       clear sql_stmt;
       //Prepare the statement with the name passed
       sql_stmt='SELECT whfnam,whlnam FROM DAVE WHERE WHPNAM='''+program+
          ''' AND WHOBJT=''P'' ORDER BY whfnam';
       exec sql prepare stmt from :sql_stmt;
       exec sql declare programs cursor for stmt;
       exec sql open programs;
       //Lets process all of the records
       exec sql fetch programs into :ProgRec;
       DOW sqlcode=0;
          output=%trim(spacer)+%trim(lname)+'/'+pname;
          write dcout;
          lines+=1;
          IF lines=50;
            write DChead;
            lines=0;
          ENDIF;
          //Recursively call with the program passed to it!
          printPrograms(pname:%trim(spacer)+'--');
          exec sql fetch programs into :ProgRec;
       ENDDO;
       exec sql close programs;
       return;
      /END-FREE
     PprintPrograms    e                            

I was wondering if there’s some way to dynamically create cursors.
 
Any ideas??

Thanks,
Dave

The post SQLRPGLE Cursors and Recursion appeared first on IT Answers.


Viewing all articles
Browse latest Browse all 16

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>