Thursday, June 5, 2008

Embedded SQL in free format RPG:

At last free-form coders no longer have to relegate SQL calls to traditional C-spec subroutines or subprocedures at the bottom of the program (or worse, break out of /Free in the middle of the program). Now, an SQL statement can be placed directly in a /Free block. This is the new features in SQL with i5/OS V5R4.. The only rules are:
• The SQL Statement must begin with EXEC SQL (on one line)
• The statement itself can span multiple lines (without a special line extender)
• The statement, like normal free format, must be terminated with a semicolon
A sample statement with host variables looks like the following in free form RPG:

EXEC SQL Select EmpName
Into :EmpName
Where EmpNo=:EmpNo;

No comments: