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



In order to load an array as the one you defined, I use a long
procedure, I wish I can do it shorter, but I didn't get it to work in
the short version.

The one that works is:

Declare X cursor for select ...
open X
fetch X for :maxLines rows into :dataDS :nullsDS

rowsReaded = sqlerrd(3)
close X

Where you need to put the EXEC SQL, fields to read, tables, etc.

maxlines is defined as a constant, and used as dimension for the dataDS.
dataDS must be QUALIFIED
nullDS uses maxLines as dimension and an array of 5i 0 times the number
of fields in dataDS
The predefined sqlerrd array returnes the number of rows read in the
third element.



On 09/14/2015 01:08 PM, Koester, Michael wrote:
I'm not real good at using sql set-at-a-time processing, so I'm hoping someone can give me some clues.

I'm okay with declaring cursors, and loading arrays with a multi-row fetch, or from "fetch next" inside a for-loop. I'm trying to improve my coding techniques, and understand the options.

I've seen mentions on this list of using "select into :ArrayDS", but whenever I try to code up such a thing, the sql precompiler says I can't - tells me my array is no good.
Specifically, "SQL0312: Position 16 Variable ArrayDS not defined or not usable."

I've tried all kinds of adjustments to simplify the host data structure to appease the precompiler, but it is not in the mood.

Compiling with CRTSQLRPGI on v7.1 with mostly up-to-date PTFs (I'm told). Could be missing one?
Or could be that I don't know what I'm doing. Or could be no one else can do this either?

Code that DOES NOT work:

DCL-DS ArrayDS QUALIFIED DIM(64);
userAcct CHAR(50);
END-DS ;

// dds-defined physical file SV02 has 3 records that meet "where" criteria.
// sv2eml is defined as character 50; sv2sts is defined as character 1.

exec sql
select sv2eml into :ArrayDS
from sv02
where sv2sts = '';

Is it just me ??? Thanks.
Michael Koester


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.