On Jan 16, 2020, at 10:44 AM, Barbara Morris <bmorris@xxxxxxxxxx> wrote:
Vern, in the earlier part of this thread from last year, this technique was
discussed (mapping a varying field across an integer followed by a string).
more stuff char(100);
dcl-s varfld varchar(100:4) based(p);
dcl-s p pointer inz(%addr(len));
Chris is doing something like that. Whether it's a good idea or not, I
think it does work.
At least, it works if the length (subfield EZDQLSTL, in Chris's case) is
less than or equal to the defined length of the based VARCHAR field.
Chris, if you can debug this, what is the value of EZDQLSTL when you do the
assignment to Upper?
date: Wed, 15 Jan 2020 19:06:10 -0600
from: Vernon Hamberg <vhamberg@xxxxxxxxxxxxxxx>
subject: Re: How do I clip a vary length field?
I think I see the problem, Chris - EZDQLSTL is defined as an integer -
it is the length of the SQL statement, not the statement itself.
There are a couple elements that are described as "varying" - IIRC, that
doesn't mean they are a varying-length field, just that the length is
not fixed in the data structure, and the length is in the above-noted
element. In working with APIs like this, you have to use the offsets and
lengths provided. The SQL statement doesn't have an offset in the DS,
since it is always at a fixed point, but the "extended cursor name" DOES
have an offset, because it is located at different places in the DS,
depending on the length of each instance, where the statements are not
the same length.
you'll need to modify things - you can use a pointer, perhaps, to the
element that follows EZDQLSTL, then a substring on the variable there
and use the length for that.
Have fun!! It's API heaven!
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link: https://amazon.midrange.com