Stored procedure support provides a means to run iSeries™ server Control Language (CL) commands by using the SQL CALL statement.
The following examples show cases where a CL command is run on the iSeries server by using the CALL statement, which calls the program that processes CL commands. That program (QCMDEXC in library QSYS) expects two parameters:
The parameters must include these attributes for the command to be interpreted properly. The second parameter on the CALL statement must have characters explicitly specified for all places of the decimal (15,5) field.
In the following example, a C program on the PC is going to run an OVRDBF command that is 65 characters long (including embedded blanks). The text of the OVRDBF command is as follows:
OVRDBF FILE(TESTER) TOFILE(JMBLIB/TESTER) MBR(NO2) OVRSCOPE(*JOB)
The code for performing this command by using ODBC APIs is as follows:
HSTMT hstmt; SQLCHAR stmt[301]; rc = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt); strcpy(stmt,"CALL QSYS.QCMDEXC('OVRDBF FILE(TESTER) TOFILE(MYLIB/"); strcat(stmt,"TESTER) MBR(NO2) OVRSCOPE(*JOB)',0000000064.00000)"); rc = SQLExecDirect(hstmt, stmt, SQL_NTS);
Statements now run against file MYLIB/TESTER will reference member number 2 rather than the first member.
Another CL command that is useful to run against a database server job is the STRDBG command. You do not have to call a stored procedure to run this command, though. There is an option on the Diagnostic tab of the DSN setup GUI on the Diagnostic tab that will automatically run the STRDBG command during the connection attempt.