1) I don't see w1 set anywhere (probably a paste failure).
2) I recommend you check SQLSTT of SQLCOD after exec sql statements. You may find that your prepare failed and that will help you track down the problem.

Sam

(Note that declare cursor and set statements don't set SQLSTT or SQLCOD.)

On 12/8/2014 10:26 AM, Billy Waters wrote:
My first attempt at using dynamic SQL. Any help would be greatly appreciated.

w2 = 'R1';
w3 = 'R9';
w4 = 2015;
w5 = 4;

WSQL = 'select sum(pinv) into ? from CMSFWRK20 ' +
'where PCLS between ? and ? ' +
'and PYEAR = ? and PPERD = ?';
Exec Sql prepare S1 from :WSQL;

Exec SQL
execute S1 using :w1, :w2, :w3, :w4, :w5;

job log shows
call test
Token ? was not valid. Valid tokens: : <IDENTIFIER>.
Prepared statement S1 not found.


---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com


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