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



Hi everyone,

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'
C/exec sql
C+ PREPARE DYNSQLSTMT FROM :query
C+ EXECUTE DYNSQLSTMT
C/end-exec

I can't even get this (or any other incantation I've tried) to compile. Does someone have some sample code of using a dynamic SQL statement to populate a subfile?

James Rich

It's not the software that's free; it's you.
- billyskank on Groklaw

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.