RPG CLI Code

Files available for download

File Name Type Description
EX01 RPGLE RPG CLI example, uses SQLExecDirect to run an SQL statement.
EX02 RPGLE RPG CLI example, uses SQLPrepare, SQLExecute to prepare and run an SQL statement with a parameter marker
CSQLCLI_HX RPGLE Include member of CLI defines and prototypes for RPGLE programs
CTYPES RPGLE Include member that defines basic C data types, referenced in CSQLCLI_HX
RPG_CLI.PDF PDF PDF file of the PowerPoint presentation

Click a file name to view it in your browser as a text file.

To save the file to your PC, right-click and select the "Save" option.

Install / Create Instructions

  1. Create library RPG_SQL on your iSeries.

  2. Create source file RPG_SQL/QSQLCLI.

  3. Upload the four source files shown above to source file RPG_SQL/QSQLCLI. The source member type for all of the source members is RPGLE.

  4. In example programs EX01 and EX02, change the value of the szDSN field name to the name of your iSeries Relational Database Directory Entry (the field value is set to M270 in the example programs). Use the WRKRDBDIRE command to view the name of the Relational Database Directory Entry on your iSeries.

  5. Use the following CRTBNDRPG commands to create the two example programs:

CRTBNDRPG PGM(RPG_SQL/EX01)  SRCFILE(RPG_SQL/QSQLCLI)

CRTBNDRPG PGM(RPG_SQL/EX02)  SRCFILE(RPG_SQL/QSQLCLI)

Note: if database file QIWS/QCUSTCDT is not your iSeries system, substitute another database file in the SQL SELECT statements in the example programs. You will also need to adjust the bound column names and attributes for the database file that you use.

** END **