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



Inherited code that I need to clean up, but the IBM DS includes the
following

D EZDRSV2 117 234
D* Res. for future use @B2C
D EZDQLSTL 235 238I 0
D* Length of SQL Stmt text@A1A
D*EZDSQLST00 239 239
D*
D* Varying length
D* /* SQL statement text @B2C
D*EZDECN00 240 240


So I assume the programmer +2 on the SQLPTR is to set XSQL1024 (misnamed
because its 9216 long) to point to the space used by EZDSQLST00 .

And as such, when the code I posted runs, UPPER=XSQL1024 it fails with
RNQ0115 Length of varying length variable is out of range

I want to prevent that error. I know I have to rewrite portions of the
program but until then I am just looking to solve the problem it has.


On Mon, Dec 9, 2019 at 11:35 AM Jon Paris <jon.paris@xxxxxxxxxxxxxx> wrote:

I'm not sure I understand the question as posed.

If you want to limit Upper to 1024 characters then define it that way e.g.

Dcl-S Upper Varchar(1024);

Then the truncation takes place on assignment.

The problem I have is why you are not just assigning EZDQLSTL directly to
upper. Why bother with XSql1024 ? Which you don't seem to be setting
correctly anyway as you are mapping the count portion over the first 2
characters of EZDQLSTL which I'm pretty sure is not what you want.

Is EZDQLSTL even a varchar? I suspect IBM define it as Char * - which does
not mean varchar - it means variable in length - not the same thing.

P.S. If you ever do need to get the address of the data portion of a
varchar then use %Addr( fieldName : *Data ) - not the + 2 method which will
fail for large fields.


On Dec 9, 2019, at 10:02 AM, C Holko <christopherholko@xxxxxxxxx> wrote:

So, I have this
XSql1024 S 9216 Varying
Based(SqlPtr)

Upper S Like(XSQL1024)

and later some code does
SqlPtr = %addr(EZDQLSTL) + 2
Upper = XSQL1024

The EZ* fields are from QSYSINC/QRPGLESRC EZDAEP coming in the exit
QIBM_QZDA_SQL2

I need to clip XSQL1024 so it will always fit in Upper. I am getting SQL
strings in excess of 9k.

What are my options?
--
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,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://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: https://amazon.midrange.com

--
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,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://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: https://amazon.midrange.com


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.