Whether it's possible or not depends on whether or not your system has the option to allow it -- the 57xx-ST1 SQL Development Kit.
The SQL Dev Kit supplies the SQL pre-compiler that processes the SQL statements to convert them into the appropriate data structures and other RPG statements so that the RPG compiler can understand them.
The SQL Dev Kit is a chargeable option. It enables all of your installed HLLs to handle embedded SQL. It also installs the STRSQL interactive SQL command and the full Query Manager user and developer interfaces.
If the SQL Dev Kit is not installed, you can still use ILE RPG to process SQL CLI API calls (i.e., ODBC).
Tom
=========================================================
Yes it's possible. you can use /exec sql and /end-exec pre compiler directives in the c- specs. In between the directives you can insert your SQL statements. The program becomes an object of type SQLRPG/SQLRPGLE depending on it's compiling environment. The compilation should be done using CRTSQLRPG/CRTSQLRPGI command and not ordinary CRTRPGPGM or CRTBNDRPG.
here is an example how it can be done:
C/exec sql
C+ select CMCSNO, --customer number
C+ CMCSNM, --customer name
C+ CMDFSH --default shipto
C+ into :csCMCSNO,
C+ :csCMCSNM,
C+ :csCMDFSH :inCMDFSH
C+ from CUSMS
C+ where CMCSNO=:customer
C/end-exec
regards
--
In addition, if you are on V5R4 or higher, you can use inline SQL statements in freeform RPG, like:
/free
...
exec sql select CMCSNO,
CMCSNM,
CMDFSH,
into :csCMCSNO,
:csCMCSNM,
:csCMCFSH
from CUSMS
where CMCSNO=:customer;
...
/end-free
If you are not V5R4, then juggling between /free and fixed format just to do embedded SQL is a pain. Anyway, just make sure that you don't forget to preface each RPG field with a colon (:). That's how the program knows whether you are referencing fields in the database or in the :program. HTH. --Koohiisan
Here is a good reference.
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/rzajp/rzajprpg.htm
Jeff