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



> Tom Tufankjian wrote:
> 
>I am using embedded SQL with a serial cursor using the 
>declare, open, fetch, close commands.  Is there a way 
>to change the WHERE statement <dynamically> in 
>the rpg program?

Sure.  Use the PREPARE statement.  Here's a brief sketch:
C/EXEC SQL                                
C+ DECLARE DYNFIL SCROLL CURSOR FOR DYNSTM
C/END-EXEC       
C* Use MOVE, CAT, etc. to build up the full statement.
C* The final result will look something like:
C* SELECT KWD,TT,INIT,TTDATE,TTDESC             
C*  FROM TTIND K,TTHDR H                        
C*  WHERE (K.TT=H.TTNUM AND K.INIT=H.TTINIT) AND
C*  KWD=                                        
C*  ORDER BY KWD,TT DESC                        
C*  FOR READ ONLY                               
C*                         
C/EXEC SQL                    
C+ PREPARE DYNSTM FROM :WWHERE
C/END-EXEC                    
C/EXEC SQL                  
C+ OPEN DYNFIL USING :WWHERE
C/END-EXEC                  
C/EXEC SQL                                                   
C+ FETCH NEXT FROM DYNFIL INTO :KWD,:TT,:INIT,:TTDATE,:TTDESC
C/END-EXEC                                                   
C/EXEC SQL     
C+ CLOSE DYNFIL
C/END-EXEC     

Notice that your FETCH has hard-coded the columns you want to return, so you
don't want to  tinker too much with the SELECT clause.

Buck Calabro
Aptis; Albany, NY
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---


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.