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



Okay, I am truly lost here. I am missing something really simple. this is a quick test program that fails when called by the exit with RNQ0115 when it does the upper=sqlstuff

RNQ0115 is Length of varying length variable is out of range.





**FREE

/copy qsysinc/qrpglesrc,ezdaep
Dcl-s pEZDQLSTL pointer inz( %Addr( EZDQLSTL ) );

Dcl-s SQLStuff VarChar(32000: 4) Based( pEZDQLSTL );

Dcl-s Upper Varchar(128);

dcl-pr ODBCEXIT extpgm('ODBCEXITN');
allow char(1);
datain likeds(EZDSQLF2);
end-pr;

dcl-pi ODBCEXIT;
allow char(1);
datain likeds(EZDSQLF2);


allow = *on;
Upper = SQLStuff; // This will truncate to 1024 if needed.

*inlr = *on;

return;



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

Sorry Chris - my brain doesn't always syntax check my code.

The simple fix is to declare and initialize the basing pointer. So code this:

Dcl-s pEZDQLSTL pointer inz( %Addr( EZDQLSTL ) );

Dcl-s SQLStuff VarChar(32000: 4) Based( pEZDQLSTL ); // Length can be anything up to 16Mb

Note that you MUST use the address of EZDQLSTL (not EZDSQLST00) as the base for the varying field.

The layout of a Varying:4 field is bytes 1 - 4 contain the active length of the field (in other words EZDQLSTL) and the data starts in byte 5 (i.e. EZDSQLST00 and subsequent bytes).



On Dec 11, 2019, at 7:26 AM, Chris Holko <christopherholko@xxxxxxxxx> wrote:

One more follow up.

%addr cannot be used as a parameter within BASED, that results in a RNF3453 - The parameter for keyword BASED is not valid.

So that I understand what is being stated, the 32000:4 puts the 32k variable at position 4 not he variable it is based upon?


So cut from copy book, see below, could I simply do the following? My difficulty in RPGLE has always been declaration of variables.

dcl-s sqlstuff varchar(32000) based(EZDSQLST00);



Copy book cut out.

D EZDLECN 113 116I 0
D* Length of ext'd cursor @B2A
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



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

Having looked at the source file I'm even more confused.

EZDQLSTL is an Int(10) containing the length of the SQL statement.

Not sure where the data itself is from the source but it looks like it may follow EZDQLSTL.

If that is the case then what you need is:

Dcl-s SQLStuff VarChar(32000: 4) Based( %Addr( EZDQLSTL ) ); // Length can be anything up to 16Mb

Dcl-s Upper Varchar(1024);

Upper = SQLStuff; // This will truncate to 1024 if needed.

I _think_ this is what you need but without knowing why you are upper casing stuff etc I'm guessing. But if the data follows the count then this should work.

Note the _4_ in the VarChar definition - the supplied length is 4 bytes so you have to ensure the definition matches.


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

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

Follow-Ups:

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.