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





>I would like to know how to insert SQL commands 
>in a RPG400 non-ILE program.

RPG IV is the way to go -- I'd seriously consider
doing new work in this language rather than RPG400.
Once you use RPG IV, you'll never want to use RPG400
again!

Having said that, the way to include SQL in RPG400
is exactly the same as in RPG IV:

C/EXEC SQL 
C+ DECLARE DTLCSR CURSOR FOR 
C+    SELECT NAME, CITY, STATE, ZIP 
C+    FROM BUCK/MASTER 
C+    ORDER BY CITY, NAME 
C/END-EXEC 
 
C/EXEC SQL 
C+ OPEN DTLCSR 
C/END-EXEC 

C/EXEC SQL 
C+ WHENEVER NOT FOUND GO TO CLSDTL 
C/END-EXEC 

C           NXTDTL    TAG 
C/EXEC SQL 
C+ FETCH DTLCSR INTO :NAME, :CITY, :STATE, :ZIP 
C/END-EXEC 
C                     EXCPTPDTL 
C                     GOTO NXTDTL 

C           CLSDTL    TAG 
C/EXEC SQL 
C+ CLOSE DTLCSR 
C/END-EXEC 

For your first few tries, print the compiler listing.
It will show you the included SQL fields that you can
use.  The critical one (for debugging) is SQLCOD, but
you may find SQLERM, SQLERP, SQLERR and SQLSTT useful.
Check the DB2/400 SQL programmer's guide for details
on syntax, etc.

hth,
Buck Calabro
CommSoft, Albany, NY
mailto:mcalabro@commsoft.net





* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This is the RPG/400 Discussion Mailing List!  To submit a new         *
* message, send your mail to "RPG400-L@midrange.com".  To unsubscribe   *
* from this list send email to MAJORDOMO@midrange.com and specify       *
* 'unsubscribe RPG400-L' in the body of your message.  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.