× 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 am a newbie and am still trying to learn RPG. I have a question regarding
CL programming. Is embedded SQL supported in CL programs? If so, are SELECT
statements supported?

In addition to Vern's excellent suggestions of QMQRY, REXX and OPNQRYF, I'd like to add these:

a) In V5R3 it's possible to call the CLI APIs from CL. This provides some interesting possibilities.

b) In earlier releases, you can run SQL via QShell commands. This can be convienient, since you can build the SQL command on-the-fly.

c) Some people advocate creating an RPG program that accepts an SQL statement as a parameter, and then simply prepares and executes it. This way you can call it from CL programs to perform SQL commands. Of coruse, this doesn't allow data to be returned (such as the result of a SELECT), but you could have SQL write the results to a file and read it from CL using RCVF.

I want to do something like

(only an example SQL statement).
'SELECT CSTNUM,  CSNAME,  CSADD1, CSADD2, CSCTST, CSZIP from MYLIB.CSTMST
WHERE CSTNUM = 'PARM1';

For that I'd probably use QMQRY.

I posted this question in rpg group but I was advised that it would be more
appropriate to post it here.

I'm not sure if you understand why that is, so I'll explain.

There are SQL programmers who are not RPG programers. There are CL programmers who are not RPG programmers. It makes sense to post your question in the correct forum. Don't post Java questions in the COBOL forum. Don't post CL questions in the RPG forum. It just makes sense!

In addition to that, the archives of the mailing lists are very valuable because when you're having a problem you can search them, find out what other people have discussed, and often solve you problems in a few minutes. To keep these archives valuable, you have to know which lists to search. For example, if I have a question about CL programming, it wouldn't make sense for me to search the Java mailing list. Therefore, it's to everyone's benefit if you post your questions to the right lists.

Remember, CL is a different language than RPG. The correct forum for CL discussions is MIDRANGE-L. The correct forum for RPG discussions is RPG400-L.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.