Chuck,
The goal is to convert existing DDS-defined DB objects to DDL. In my POC sampling, there is a Select/Omit logical file that I am trying to emulate using SQL.
After much trial and error, I managed to get the result set of properly ordered, properly selected data using a combination of a VIEW to limit the rows (the S/O criteria) and an INDEX to produce the order.
Now, before you all start to beat me about the head and shoulders, I know that this isn't a solution. My test is lucky to have the SQL Engine select the INDEX I wanted it to. But there is no way (to my knowledge) to force a particular INDEX selection by the engine.
But you said something that triggered something...I didn't think to add an INDEX using the WHERE clause, so I created an INDEX (after all, I'm trying to emulate a logical file). This was great...except that it returned only the columns listed in the key-expression. I had to use RCDFMT, name the format and indicate to use all columns.
CREATE INDEX NEEDLES/INDEX07 ON NEEDLES/TABLE (Fld1, Fld2)
where Fld4 = 'Y'
RCDFMT FORMAT ADD ALL COLUMNS
My thanks to all of you that chimed in!
Steve Needles
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of CRPence
Sent: Wednesday, June 05, 2013 12:42 PM
To: midrange-l@xxxxxxxxxxxx
Subject: Re: Create view using CTE as to have an ORDER BY
On 05 Jun 2013 09:01, Needles,Stephen J wrote:
DRAT!! It was worth a try. Thanks all.
If anyone comes up with a solution, please advise!!
CREATE TABLE /* as Materialized Query Table (MQT) */ or DECLARE GLOBAL TEMPORARY TABLE can be used to create a /temporary/ table [as a more costly permanent object vs the true-temporary CTE] if the effect of a temporary copy of the [ordered] data has some specific value for other work [outside the scope of the query that might otherwise want to define its temporary table as a CTE].
Or if the goal was to use the VIEW in RLA vs an SQL SELECT query, then besides either of the above, one of the following might be useful:
- use a DDS LF with Select\Omit logic [optionally DYNSLT]
- use CREATE INDEX with a WHERE clause
- use OPNQRYF on the VIEW with a KEYFLD() specification, and share that ODP with the RLA program
--
Regards, Chuck
--
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.
________________________________
This communication, including attachments, is confidential, may be subject to legal privileges, and is intended for the sole use of the addressee. Any use, duplication, disclosure or dissemination of this communication, other than by the addressee, is prohibited. If you have received this communication in error, please notify the sender immediately and delete or destroy this communication and all copies.
TRVDiscDefault::1201
As an Amazon Associate we earn from qualifying purchases.