SQL programming considerations for IBM i
Learn about the steps required when building an application on IBM i using SQL.
If your program contains EXEC SQL statements and MQI calls, perform these steps:- Translate the EXEC SQL commands into native language statements. Use the CRTSQLCI command for a
C program. Use the CRTSQLCBLI command for a COBOL program.
Include OPTION(*NOGEN) in the CRTSQLCI or CRTSQLCBLI command. This halts processing to enable you to include the appropriate IBM MQ service programs. This command puts the code, by default, into QTEMP/QSQLTEMP.
- Compile the source code using the CRTCMOD command (for a C program) or the CRTCBLMOD command (for a COBOL program).
- Use CRTPGM to link the compiled code with the appropriate IBM MQ service programs. This creates the executable program.
An example of such code follows (it compiles a program, SQLTEST, in library, SQLUSER):
CRTSQLCI OBJ(MQTEST/SQLTEST) SRCFILE(SQLUSER/QCSRC) + SRCMBR(SQLTEST) OUTPUT(*PRINT) OPTION(*NOGEN) CRTCMOD MODULE(MQTEST/SQLTEST) + SRCFILE(QTEMP/QSQLTEMP) OUTPUT(*PRINT) CRTPGM PGM(MQTEST/SQLTEST) + BNDSRVPGM(QMQM/LIBMQIC)Parent topic: Building your procedural application on IBM i