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



I have a need to accept a list of values that needs to be compared to a column in a table using an embedded SQL statement in RPGLE.

The list:

'data1'
'data2'

This list is assembled so that path looks like:

'data1','data2'

When used in the SQL statement...

Select stuff from table where column3 in (:path);

I end up with an SQLCod = 100.

Running the SQL outside of the program produces the needed data.

Select * from table where column3 in ('data1','data2');

Is there a solution short of repeating the condition over and over again? Using STRIP and TRIM with the host variable had no impact.

Stub of Code below:

dpath s 9999

dcolumn1 s 5
dcolumn2 s 3
dcolumn3 s 9999

/free
eval path = '''';
eval path = %trim(path) +
'data1' + '''';

eval path = %trim(path) + ',' + '''' +
'data2' + '''';

exec sql
declare get cursor with return to client for
SELECT distinct
Column1, Column2, Column3 FROM Table WHERE
Column3 in (:path);

exec sql open get;

exec sql fetch get into :Column1, :Column2, :Column3;

if sqlcod = sqlcod;
eval sqlcod = sqlcod;
endif;

/end-free



==============================================================================
This communication, including attachments, is confidential, may be subject to legal privileges, and is intended for the sole use of the addressee. Any use, duplication, disclosure or dissemination of this communication, other than by the addressee, is prohibited. If you have received this communication in error, please notify the sender immediately and delete or destroy this communication and all copies.

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.