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



Thanks Phil and Tommy...that's what I suspected.

> -------- Original Message --------
> Subject: Re: Embedded SQL - Variable File Name
> From: Phil Groschwitz <ssc1478@xxxxxxx>
> Date: Thu, December 01, 2005 10:40 pm
> To: RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>
> 
> On Thu, 2005-12-01 at 19:47 -0500, Michael Ryan wrote:
> > Why can't I do this?
> > 
> > C/Exec SQL         
> > C+ Select Sum(IOQTYO)
> > C+   Into :pWkQuan :WkNull
> > C+   From :MyFile  
> > C+   Where IOITEM = :pWkItem And
> > C+         IOWHSE = 'PH'     And
> > C+         IODELE <> 'D'
> > C/End-Exec         
> > 
> > Where MyFile is a variable. I get a "Token : was not valid. Valid tokens: (
> > TABLE LATERAL <IDENTIFIER>." message.
> 
> I don't think you can do this unless you use a cursor and define the
> entire statement in a variable.  Here's a non-working example that might
> help you out:
> 
> 
> D my_host_data_structure...
> D
> D                          ds             7p 0
>  /free
>  my_variable = 'select sum(iootyo) from ' + myfile + ' where ioitem =
> pwkitem;
>  /end-free
> 
> C/exec sql
> C+ declare my_statement from :my_variable
> C/end-exec
> 
> C/exec sql
> C+ prepare my_cursor cursor using :my_statement
> C/end-exec
> 
> C/exec sql
> C+ open my_cursor
> C/end-exec
> 
> C/exec sql
> C+ fetch my_cursor into :my_host_data_structure
> C/end-exec
> 
> C/exec sql
> C+ close my_cursor
> C/end-exec
> 
> The info center has good docs on this nowadays.  Search for prepared
> statements.
> 
> -- 
> This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
> To post a message email: RPG400-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
> or email: RPG400-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/rpg400-l.


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.