I have read the answers and the documentation and I disagree with your
assessment of my problem. Since I don't know the file or fields in advance,
using set descriptor means that I have to change the field definition of
every field that I am retrieving to make it work. That leads to a lot of
convoluted code.

for fieldno = 1 to numColumns
select
when fieldtype = character
set descriptor local :descName
value :fieldno
length = 32000;
when fieldtype = numeric
set descriptor local :descName
value :fieldno
length = x;
when fieldtype = decimal
set descriptor local :descName
value :fieldno
length = x,x; <== I didn't look this up
endsl;
endfor;

And, if I make it completely generic as requested, I have to include a
similar block of code for all of these types too.

BIGINT
VARCHAR(n)
DATE (DATETIME_INTERVAL_CODE = 1)
TIME (DATETIME_INTERVAL_CODE = 2)
TIMESTAMP (DATETIME_INTERVAL_CODE = 3)
BINARY(n)
VARBINARY(n)
DOUBLE PRECISION
FLOAT
INTEGER
ZONED DECIMAL(n)
REAL
ROWID
SMALLINT

Have I missed something in the answers or documentation?



-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of D*B
Sent: Monday, September 4, 2017 1:06 PM
To: RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
Subject: Re: Building dynamic SQL with descriptors

<John>
I really can't believe IBM didn't take that last step to figure out how to
put values from the descriptor into a generic sized variable. Let me define
variables of 32K (or whatever) for chars, 13,15 for decimals, etc. and be
able to use them generically.
</John>

Why don't you read the answers? That's what "SET DESCRIPTOR" is made for!!!

D*B

PS: the problem is not dynamic allocating memory! The problem is to bring
data of one type to another type with a language ("RPG") which is dealing
under the coever with binary data.

--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link:
http://amzn.to/2dEadiD


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