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




Jeff,

If you want to keep everything in a single RPG program you can use
QCMDEXEC or the equivalent API (The name escapes me at the moment) to
issue the OVRDBF command before running your SQL.

Rick

-----Original Message-----
From:
rpg400-l-bounces+rick.chevalier=americredit.com@xxxxxxxxxxxx
[mailto:rpg400-l-bounces+rick.chevalier=americredit.com@midran
ge.com] On Behalf Of Jeff Crosby
Sent: Tuesday, July 18, 2006 6:16 AM
To: 'RPG programming on the AS400 / iSeries'
Subject: RE: SQL Alias within RPG

Thanks for replying.  You must really know your SQL as you
respond to virtually all SQL questions here.  That's really
helpful to those of us getting our feet wet.

you definitely have to use dynamic SQL.

<snip>

Here an example:

/Free
   CmdString = 'CREATE ALIAS MYALIAS FOR MYTABLE (' +
%Trim(MyMember) + ')';
   Exec SQL  Execute Immediate :CmdString; /End-Free

Thanks for the examples.  I'm going to do some experimenting today.

BTW I wouldn't create an alias at runtime. Aliases are permanent
objects
(DDM-Files) that can be created once and used when ever
needed. If the
members you have to read change every day, I'd suggest to use the
CL-Command OVRDBF to override the member and use it in the SQL
statments

I understand it's permanent.  Normally when I require a
specific member in RPG, an OVRDBF in CL is what I do.  What I
was planning to do in RPG was 1) create the alias, 2) use it,
and then 3) delete it.  It's used once a month (not daily)
for this report and that's it.  Next month a different member
will be used.  My reasoning for wanting to do it this way was
that everything (including the 'override') would be contained
within this RPG program.  Your suggestion is when I need a
specific member in SQL RPG is to break down and use OVRDBF
just like 'regular' RPG, right?

Thanks again.

--
Jeff Crosby
Dilgard Frozen Foods, Inc.
P.O. Box 13369
Ft. Wayne, IN 46868-3369
260-422-7531

Privileged and Confidential.  This e-mail, and any attachments there to, is 
intended only for use by the addressee(s) named herein and may contain 
privileged or confidential information.  If you have received this e-mail in 
error, please notify me immediately by a return e-mail and delete this e-mail.  
You are hereby notified that any dissemination, distribution or copying of this 
e-mail and/or any attachments thereto, is strictly prohibited.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.