We released an enhancement last May for 7.3 and 7.4 that allows you to use
a single OPEN statement for a situation like you describe. Using something
called extended indicators, you can mark host variables in the OPEN to be
ignored. It requires adding the SUBSET keyword to your OPEN and adding
indicator variables for the host variables that you want to control. See
this wiki page for details: https://www.ibm.com/support/pages/node/6174207

Sue Romano
Db2 for IBM i Development


Happy New Year to all.

I need to open a cursor but the number of parameter markers is not known
until run time.
I'm doing this right now with a SELECT statement in RPG but wondering if
this can be softcoded in some way. What I have is...

// We now need to open the statsCursor with the correct number of
parameter
markers
Select;
When fileCount = 1;
Exec sql
OPEN statsCursor USING :fromTs, :toTs;
When fileCount = 2;
Exec sql
OPEN statsCursor USING :fromTs, :toTs, :fromTs, :toTs;
When fileCount = 3;
Exec sql
OPEN statsCursor USING :fromTs, :toTs, :fromTs, :toTs, :fromTs,
:toTs;
Endsl;

Currently this is coded for 3 files, but this can easily be 10 or more
files at run time.

Do I have any other options for OPENing the cursor?

Thanks,

Rob


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.