× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



-- In RPG there is only a single rule: The DECLARE Statement must be
physically coded BEFORE the OPEN statement, independent in which
sequence they are executed.

This doesn't appear to be the case in V7R1 TR7.

Now you can put the DECLARE statement after the Open statements.

Tested with this subprocedure:

P GetSummary B
D GetSummary PI
D LKeyDs 3p 0 const
D Lcount 10p 0

D Rssummary DS QUALIFIED
D Count 10P 0
D Rssummaryin DS Qualified
D Sts 3p 0

D SummarySql S 32740A VARYING Static

D/Free

If SummarySql = *Blanks;
Exsr PrepareStuff;
Endif;


Rssummaryin.Sts = LKeyDs;
Exec Sql Open Ret65f_SummaryCsr using :RsSummaryIn;
If Sqlstate= '24502';
Exec sql Close Ret65f_SummaryCsr;
Exec Sql Open Ret65f_SummaryCsr using :RsSummaryIn;
Endif;
If sqlstate <> '00000';
Callp Tlk_SndSqlError(SQLCODE :SQLERRMC : SummarySql );
Endif;

Exec sql Fetch from Ret65f_SummaryCsr into :RsSummary;
If sqlstate <> '00000';
Callp Tlk_SndSqlError(SQLCODE :SQLERRMC : SummarySql );
Clear RsSummary;
Endif;
Exec Sql Close Ret65f_SummaryCsr;

Lcount = RsSummary.Count;

Return;

Begsr preparestuff;

SummarySql ='Select Count(Ststn) From Rimstmpf Where Stssts =
?';
Exec sql Prepare Ret65f_SummaryStm From :SummarySql;
IF (SQLSTT <> '00000');
CALLP Tlk_SndSqlError(SQLCODE :SQLERRMC :SummarySql);
ENDIF;
Exec sql Declare Ret65f_SummaryCsr Cursor for
Ret65f_SummaryStm;

Endsr;
/End-free
P GetSummary E


Chris Hiebert
Senior Programmer/Analyst
Disclaimer: Any views or opinions presented are solely those of the
author and do not necessarily represent those of the company.

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.