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



John,

Your basic line for this would be:

Using COMPANY as file name CPNAME as Company Name, CPKey as Company
number
wCPName and wCPKey are the work fields you define in RPGLE.


Exec SQL
Select CPNAME into :wCpName from Company where CPKEY = :wCPKey;



Oh, this V5R4 syntax.


Sharon Wintermute


-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of John Allen
Sent: Thursday, November 12, 2009 10:23 AM
To: MIDRANGE-L@xxxxxxxxxxxx
Subject: Looking for BASIC example of using embedded SQL for retrieving
fieldvalue

I have finally got the opportunity to learn embedded SQL in RPG ILE.

I have been searching on the web for the most basic example I can find
for
my application
but everything I find has more then I need (I think) and it is
confusing.



I find I can learn much quicker by seeing an example.

Does anyone have or can anyone point me to an example that does the
following (No more, no extra stuff that will confuse me)



I have a physical file with 10 fields (COMPANY)

The unique key field (Company Number) is two character field (Alpha),
The 5th field in the company file is a variable length field (Company
Name).

The only parameter I have coming in is the key value.



I would like to use SQL to retrieve the record for the key value
(Company
Nbr) and get the value in the 5th field (Company Name) and place it in a
work field.



No updating, No deleting, just take the key value retrieve the company
name
and place it in a work field



I know this is very easy to do with a simple chain, but I believe we
could
do a lot more with embedded SQL in other programs
so I want to learn how to do this with SQL. Then hopefully all the other
examples on the web will make sense to me.





Thanks in advance

John




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.