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



Try this:
        https://www.mcpressonline.com/programming/sql/using-dynamic-sql-in-cl-part-2retrieving-a-data-value  ;


On Friday, June 3, 2022, 05:31:43 PM EDT, Steve McKay <samckay1@xxxxxxxxx> wrote:

How can I run an SQL statement and retrieve the results into a CL pgm?

For example, I want to SELECT COUNT(*) FROM QSYS2.ASP_INFO: but I want to
run it using RUNSQL in a CL program and get the COUNT into a variable in
the CL program.

Something like this:
DCL &COUNT *DEC LEN(1)
RUNSQL SQL( SELECT COUNT(*) FROM QSYS2.ASP_INFO)
and get the SQL statement result in the CL &COUNT field.

Ultimately, I want to do different things depending on whether there is 1
ASP or more than 1 ASP so I'm really after the count of ASPs on the
system.  If there is a better way to do this within CL, I'm open to
suggestions.

Thanks,

Steve McKay
(205) 585-8424
samckay1@xxxxxxxxx

As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.