× 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'm trying to use the following embedded SQL in an RPG IV program:

EXEC SQL
select count(*) into :count from :table
where dlitm# = :item# and dldate >= :lastWeek;

I was trying to use "from :table" because our History tables get pushed at year-end close into a new library, such as HIST2007. Next year at this time, the library will be named HIST2008 so I wanted to be "flexible".

I tried using a PREPARE and dynamic SQL, but it didn't like the INTO clause.

The manuals and Redbooks don't say that the FROM clause can't take a variable, but they come awfully close (semantics). But I thought that, if anyone has figured out a way to circumvent the rules, it would be someone on the list. Hopefully, when I get back on Monday morning, someone (or more) of you will have shown me the error of my ways so that I don't have to do USROPN's with EXTFILE( ) and actually read the table.

Thanks.

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.