Difference between revisions of "SQLRPGLE"
From MidrangeWiki
(→RPG IV with Embedded SQL) |
(→Introduction to RPG IV with Embedded SQL) |
||
Line 12: | Line 12: | ||
C/END-EXEC | C/END-EXEC | ||
</pre> | </pre> | ||
− | + | == SQL Directives == | |
<table style="table-layout: auto; border-width: thin; border-color: navy; border-style: ridge inset"> | <table style="table-layout: auto; border-width: thin; border-color: navy; border-style: ridge inset"> | ||
<tr><th colspan=3 style="color: WHITE; background-color: NAVY">SQL Directives</th></tr> | <tr><th colspan=3 style="color: WHITE; background-color: NAVY">SQL Directives</th></tr> | ||
Line 20: | Line 20: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
− | <th>SELECT</th> | + | <th style="border-color: navy; border-style: solid">SELECT</th> |
− | <td>The '''Select''' directive is used to extract data from a Physical file or Table</td> | + | <td style="border-color: navy; border-style: solid">The '''Select''' directive is used to extract data from a Physical file or Table</td> |
+ | </tr> | ||
+ | <tr> | ||
+ | <th style="border-color: navy; border-style: solid">DECLARE</th> | ||
+ | <td style="border-color: navy; border-style: solid">The '''Declare Cursor''' directive is used to define a data path in your program</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <th style="border-color: navy; border-style: solid">OPEN</th> | ||
+ | <td style="border-color: navy; border-style: solid">The '''Open Cursor''' directive is used to open a data path defined by a '''Declare Cursor''' directive.</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <th style="border-color: navy; border-style: solid">CLOSE</th> | ||
+ | <td style="border-color: navy; border-style: solid">The '''Close Cursor''' directive is used to close a data path opened by a '''Open cursor''' directive</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <th style="border-color: navy; border-style: solid">FETCH</th> | ||
+ | <td style="border-color: navy; border-style: solid">The '''Fetch''' directive is used to extract records from a data path opened via the '''Open Cursor''' directive</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <th style="border-color: navy; border-style: solid">PREPARE</th> | ||
+ | <td style="border-color: navy; border-style: solid">The '''Prepare''' directive is used to prepare an dynamic SQL statement for execution</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <th style="border-color: navy; border-style: solid">EXECUTE</th> | ||
+ | <td style="border-color: navy; border-style: solid">The '''Execute''' directive is used to execute an dynamic SQL statement prepared via the '''Prepare''' directive</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <th style="border-color: navy; border-style: solid">EXECUTE IMMEDIATE</th> | ||
+ | <td style="border-color: navy; border-style: solid">The '''Execute Immediate''' directive is used to execute an SQL statement directly & does not require a '''Prepare''' directive</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <th style="border-color: navy; border-style: solid">DELETE</th> | ||
+ | <td style="border-color: navy; border-style: solid">The '''Delete''' directive is used to delete data from a Physical file or Table</td> | ||
</tr> | </tr> | ||
+ | <tr> | ||
+ | <th style="border-color: navy; border-style: solid">DROP TABLE</th> | ||
+ | <td style="border-color: navy; border-style: solid">The '''Drop Table''' directive is used to delete a Physical file or Table</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <th style="border-color: navy; border-style: solid">CREATE TABLE</th> | ||
+ | <td style="border-color: navy; border-style: solid">The '''Create Table''' directive is used to create a Physical file or Table</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <th style="border-color: navy; border-style: solid">ALTER TABLE</th> | ||
+ | <td style="border-color: navy; border-style: solid">The '''Alter Table''' directive is used to change file & field attributes in a Physical file or Table</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <th style="border-color: navy; border-style: solid">UPDATE</th> | ||
+ | <td style="border-color: navy; border-style: solid">The '''Update''' directive is used to update data from a Physical file or Table</td> | ||
+ | </tr> | ||
+ | |||
</table> | </table> |
Revision as of 18:12, 29 June 2005
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 |