SQLRPGLE

From MidrangeWiki
Revision as of 12:13, 29 June 2005 by TomHolden (talk | contribs) (SQL Directives)
Jump to: navigation, search

RPG IV with Embedded SQL

Introduction to RPG IV with Embedded SQL

SQL is a powerful tool in any programmer's skill set. It is possible to leverage this tool from within RPG (& other languages). The source member type for these programs is SQLRPGLE. Here is an example of an embedded SQL statement:

     C/EXEC SQL
     C+ SELECT * FROM mylib/myfile
     C/END-EXEC

SQL Directives

SQL Directives
Directive Function performed
SELECT The Select directive is used to extract data from a Physical file or Table
DECLARE The Declare Cursor directive is used to define a data path in your program
OPEN The Open Cursor directive is used to open a data path defined by a Declare Cursor directive.
CLOSE The Close Cursor directive is used to close a data path opened by a Open cursor directive
FETCH The Fetch directive is used to extract records from a data path opened via the Open Cursor directive
PREPARE The Prepare directive is used to prepare an dynamic SQL statement for execution
EXECUTE The Execute directive is used to execute an dynamic SQL statement prepared via the Prepare directive
EXECUTE IMMEDIATE The Execute Immediate directive is used to execute an SQL statement directly & does not require a Prepare directive
DELETE The Delete directive is used to delete data from a Physical file or Table
DROP TABLE The Drop Table directive is used to delete a Physical file or Table
CREATE TABLE The Create Table directive is used to create a Physical file or Table
ALTER TABLE The Alter Table directive is used to change file & field attributes in a Physical file or Table
UPDATE The Update directive is used to update data from a Physical file or Table