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



Hello all,

I'm trying to use dynamic embedded SQL to retrieve a value in a program.
I was originally trying to use host variables for the needed data but then
I found out that you can't use host variables in dynamic SQL and that you
have to use parameter markers instead. So here's what I have:

MySQLText = 'Select rrn(a), a.' + %Trim(Field_Name) +
' Into ?,?' + ' From ' +
%Trim(Library_Name) + '/' + %Trim(File_Name) +
' a where rrn(a) = 1';

exec sql
SET OPTION
commit=*none,
datfmt=*iso;

exec sql prepare selectRecord from :MySQLText;
exec sql execute selectRecord using :rrn,:OldCompany;

When I run the program in debug, the MySQLText field looks like this:

Select rrn(a), a.CONO15 Into ?,? From COPYAULT2/INP15 a wher
e rrn(a) = 1

and I get the following errors:

Token ? was not valid. Valid tokens: : <IDENTIFIER>.
Prepared statement SELECTRECORD not found.


I'm stumped as to what to do from here. This SQL statement should yield
one record (and does when run interactively) and the thing I'm trying to
grab is the value in :OldCompany.

Any help would be MOST appreciated. Thanks!

Bill

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.