×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




One thing, Erick, those SQL statements don't need to be run Execute Immediate, you get better performance just running the statement itself:

exec sql DROP ALIAS QTEMP/AA;
exec sql CREATE ALIAS QTEMP/AA FOR QTEMP/DISP(DISP);

But using embedded SQL, you need to "Select/Into/" some host variable. It has to return one row only, but your statement does that.

exec sql SELECT MAX( LENGTH( TRIM(DISP) ) ) INTO :MyVar FROM QTEMP/AA

Where after executed, MyVar should have the value of the length of the longest line.





On 10/23/12 7:48 PM, Erick Garske wrote:
I have a SQLPRGLE program compiled to a target release of V5R4M0
that works correctly in V7R1M0, but throws a SQL exception when
processing the prepare statement. The purpose of the
code is to simply find the longest line in the file.

/ Eval cmdSQL = 'DROP ALIAS QTEMP/AA';
/ exec sql Execute Immediate :cmdSQL;
/
/ Eval cmdSQL = 'CREATE ALIAS QTEMP/AA FOR QTEMP/DISP(DISP)';
/ exec sql Execute Immediate :cmdSQL;
/
/ cmdSQL = 'SELECT MAX( LENGTH( TRIM(DISP) ) ) FROM QTEMP/AA';
/ exec sql prepare s1 from :cmdSQL;

SQL values after processing the prepare statement:

sqlcod = 204
sqlerm =
....5...10...15...20...25...30...35...40...45...50...55...60
' *ALL *N MEM '
' '

Does anyone know if there is an issue with the above code?


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