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



Yes, as I said in my post, if one wants a table, use RUNSQL or RUNSQLSTM (before 7.1, if you don't have RUNSQL).

If the goal is to _display_ the results, QMQRY is the easiest way, or maybe the QShell db2 function. I don't know if the db2 function allows SELECT.

Vern

On 7/2/2013 11:58 PM, Birgitta Hauser wrote:
If you can execute RUNSQL, I'd neither use Query/400 nor QMQRY.
Even though SELECT is not supported, it is possible to create a (temporary)
SQL view representing the result of an SELECT statement. This view can be
registered with the DCLF command and read with the RCVF command.
The only downside is, the sequence of rows returned by the view cannot be
predefined.

If the records must be returned in a specific sequence, creating a temporary
table based on a SELECT statement with an ORDER BY clause and reading this
temporary table may be an option.

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"

-----Ursprüngliche Nachricht-----
Von: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] Im Auftrag von Vernon Hamberg
Gesendet: Tuesday, 02.7 2013 15:45
An: Midrange Systems Technical Discussion
Betreff: Re: how to use sql distinct in CL?

You have a couple options - do you want to create a table with the results?
Or do you need to display them?

If a result table, and you are at 7.1, you can use the new RUNSQL command -
it cannot do SELECTs directly.

With an older release and up, you can create a source member and use
RUNSQLSTM.

I suggest forgetting about Query/400 - unless it's an already-existing one -
and use QM queries. Those can have SQL statements - even SELECT.
You can even take your Query/400 and convert it to a QM query, then add the
distinct to the result there.

CRTSRCPF YOURLIB/QQMQRYSRC RCDLEN(91)

RTVQMQRY QRY400NAME YOURLIB/QQMQRYSRC (something like that - prompt
the command)

Check the result for what you want - there are some odd things when
converting to QMQRYs.

Open the source member you get and see a SELECT statement - add the DISTINCT
as you need.

CRTQMQRY over that source member.

STRQMQRY to run it in CL - ba-da-boom!

HTH
Vern

On 7/2/2013 8:30 AM, Hoteltravelfundotcom wrote:
I have a ad hoc process, where I can make use of the DISTINCT feature
of SQL

THe CL would first run query400 then I need the results as

Distinct.

Can you do that SQL statement in a CL?
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/midrange-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.