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

I really can't quite see how an RPG makes this simpler - the original
requirements were for a simple SQL with no error checking or logic.

If I use an RPG I now have to code and compile an additional program and
recompile every time I want to change my SQL. If I use a QM Query I simply
have to edit the QM Source member with the SQL statement.

Data queues add even more complexity if I involve them, so given the terms
of the original request it still seems to me that running a QM Query is the
simplest way to get there.

If you want anything else - like error handling or a dynamic SQL statement -
then I agree that an RPG would probably be the way to go but for the
original request, I think it's overkill.

The QM Query approach is primitive but effective if you just want to run a
query - and it nicely externalises the SQL from the CL.

Regards
Evan Harris

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Friday, 18 April 2008 8:53 a.m.
To: Midrange Systems Technical Discussion
Subject: Re: Simplest Way to run SQL in a CL?

Heh... the simplest way is to call an RPG program ! (or any other HLL)

CL doesn't have an embedded SQL preprocessor. Tools like RUNSQLSTM and
QMQRY don't have a way of reading the result of a SELECT statement. I
suppose you could use one of those tools (RUNSQLSTM et al) to write the
results of your select statement to a file, then read the file with
RCVF... but I'd find that cumbersome.

One way to wrok around it is to use Qshell to run the SQL, and have it
write the result to a data queue. While CL is very limited in it's
ability to read files, it's not so limited with data queues. I wrote an
article about that, at the following link, if you're interested:
http://systeminetwork.com/article/read-sql-result-sets-cl-qshell

If you're running V5R3 or later, it's also possible to call the SQL CLI
APIs directly from CL. Perhaps not for the feint-of-heart, but it works
and doesn't require QShell or any other special licpgms.
http://systeminetwork.com/article/database-access-cl-sql-cli

So these are possibilities... but, IMHO, if you're already familair with
doing the SQL from RPG, and you're looking for the "easiest" solution...
the easiest solution is to call an RPG program from CL.



Hatzenbeler, Tim wrote:
I need to do a very simple 'select distinct' type of SQl, and have
the results go into an existing pf, what's the simplest way to do
this in a CL?

I normally use RPG for SQl, but this particular need doesn't require
any error checking or logic associated with it.



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.