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



Unless something has changed in V5R4 or V6R1 I believe you need to specify a
MOD (multiple occurance data structure) vs. an array to accomplish what you
are attempting.

Take a look at the tech-tip I wrote back in 2004 showing how to do this:

http://systeminetwork.com/article/club-tech-iseries-programming-tips-newslet
ter-14

Do a search on that page for "2. RETURN SQL RESULT SET FROM RPG TO JAVA"

HTH,
Aaron Bartell
http://mowyourlawn.com

Btw, rockin' to Dashboard Confessional tonight
(http://www.purevolume.com/dashboardconfessional). Check out song
"Vindicated". A hopeful song for RPG programmers drowning in a .NET world
:-)



-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Joe D
Sent: Saturday, March 01, 2008 8:38 PM
To: RPG programming on the AS400 / iSeries
Subject: Use SQL to load an Array

Hi All,

I have tried every variation I can think of, and every example I have found
on the List and elsewhere via Google. I must be missing something obvious.

I have a simple array containing a part number and quantity. I want to use
SQL to populate the array, and I am almost sure I can do it in a single
statement.

Using just a 'Select Into' the array winds up with all 50 elements having
the same values. I also tried using a Cursor/Fetch Into with the same
results. At this point I have spent hours on something I though would take
five minutes.

Here is the simplist variation I have tried. If anyone can tell me what I
am missing I would greatly appreciate it.

FYI - There are only 7 items with CLASS=Z, so it would not overflow the
array. Once I get it working the way I want I will limit the number of rows
returned in the production app.

H DFTACTGRP(*NO)

DarrDs ds qualified dim(50)
D SKU 15a
D Qty 7s 0

/free
exec sql
Select
SKU, QTY
Into
:arrDs
From
ONHAND
Where
CLASS='Z';

*inlr = *on;
Return;

/end-free

Thanks!
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.