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



----- Original Message -----
From: "David FOXWELL" <David.FOXWELL@xxxxxxxxx>
To: "RPG programming on the AS400 / iSeries" <rpg400-l@xxxxxxxxxxxx>
Sent: Monday, March 03, 2008 12:34 AM
Subject: RE: Use SQL to load an Array

I didn't quite understand where you get the compile error SQL5011 from. Where was the dim(%elem(arrds) coded ?

I was receiving this error when the array DS used on the Fetch Into was defined in the D-Specs like this:
D arrDs ds likeds(otherDs) dim(%elem(otherDs))

The SQL procompiler does not resolve deep enough to determine how many elements were defined in otherDs, so it throws an exception when you try to do a multi-row fetch into the new DS (arrDs). Because it does not resolve the %elem() it does not see arrDs as an array at all, so no multirow Fetch is allowed.

Also, this is the first time I've seen something like : fetch c1 for 50 rows into :arrDs; Does the number of rows have to be hard - coded?

I do not think the number of rows needs to be hard-coded for the program to work. If you do not limit the returned row count you would probably (hopefully?) get some sort of runtime exception if the array were overflowed. By hard-coding a number that is higher than I ever anticipate needing I have ensured myself of avoiding the overflow error. However, if my future need assessment proves to be faulty, hardcoding has now created an invisible bug: If there were 57 rows of matching data, I would only get the first 50 back and there would be no exception raised.

JD

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.