× 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.



<snip>
I've been struggling with embedded SQL in RPG. I need to create dynamic

statements. Here's what I'm trying to get to work:

Dquery S 1024A
...
C if (company <> 0)
C eval query = 'DECLARE C1 CURSOR FOR SELECT ' +
C 'PENAME,PEADR1,PESS#,PEEMP# ' +
C 'FROM PRMSTP ' +
C 'WHERE (PENAME LIKE :csgrpkwda) AND ' +
C '(PECO# = :co#0) ' +
C 'ORDER BY PENAME'
C else
C eval query = 'DECLARE C1 CURSOR FOR SELECT ' +
C 'PENAME,PEADR1,PESS#,PEEMP# ' +
C 'FROM PRMSTP ' +
C 'WHERE (PENAME LIKE :csgrpkwda) ' +
C 'ORDER BY PENAME'
C endif
C/exec sql
C+ PREPARE DYNSQLSTMT FROM :query
C+ EXECUTE DYNSQLSTMT
C/end-exec
C eval query = 'OPEN C1'
</snip>

There was just a thread on this. You need ? for parameter markers.

Exec Sql Prepare M1 From :S1;
Exec Sql Execute M1 Using :V1,:V2; //Assuming two parameters.

Look for PREPARE in archives.



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.