This example demonstrates how to call a procedure with both input and output host variables:
CREATE STATEMENT PROC1 CALL PROC('ABC', :inoutvar, :invar)
The procedure used is created by:
CREATE PROCEDURE proc1 (IN par1 VARCHAR(100),
INOUT par2 INTEGER,
IN par3 INTEGER)
BEGIN
SET par2 = par2 * par3 + character_length(par1);
END
The precompiled statement PROC1's first parameter is both input and output and the second parameter is input only.
exec sql begin declare section;
int i1, i2;
varwchar_t st[100];
exec sql end declare section;
exec sql connect to ' ' user 'JOE' using 'Secret';
wcscpy(st, L"execute statement PROC1");
exec sql prepare STAT3 from :st;
i1 = 22;
i2 = 30;
exec sql execute STAT3 using :i1, i2;
exec sql commit work;
printout("InOutVar = %d\n", i1);
exec sql disconnect;
Note: The names used for host variables in the CREATE STATEMENT are not significant. It is the order the host variables appear in the statement that is significant.
For more information on preprocessing embedded SQL, see Mimer SQL Programmer's Manual, Processing ESQL.