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).
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+ select CMCSNO, --customer number
C+ CMCSNM, --customer name
C+ CMDFSH --default shipto
C+ into :csCMCSNO,
C+ :csCMDFSH :inCMDFSH
C+ from CUSMS
C+ where CMCSNO=:customer
In addition, if you are on V5R4 or higher, you can use inline SQL statements in freeform RPG, like:
exec sql select CMCSNO,
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