Using INCUDE statement, we can include source to the stored procedure. In this example, we are going to insert C source code which contains the API Qp0zLprintf.
Create stored procedure MYPRINTF like below :
cl:addlible qsysinc;
create or replace procedure mylib.myprintf(printString varchar(500))
set option bindopt = ‘bndsrvpgm(qsys/qp0zcpa)’
begin
if printString is not null then
include mylib/qcsrc(myprintf);
end if;
end;
Create Source PF QCSRC in MYLIB. Add the member MYPRINTF
{
extern int Qp0zLprintf (char *format, …);
Qp0zLprintf(“%.*s\n”, MYPRINTF.PRINTSTRING.LEN, MYPRINTF.PRINTSTRING.DAT);
}
Call the stored procedure :
CALL MYLIB.MYPRINTF(‘Hello joblog from SQL’);