Calling stored procedures with supported databases / Stored procedure call with IBM Informix |
To return values from an IBM® Informix® SPL routine, execute the routine and fetch the output values, as you would for a regular SELECT statement producing a result set.
PREPARE stmt FROM "execute function proc1(?)"
In order to retrieve returning values into program variables, use an INTO clause in the EXECUTE instruction.
MAIN DEFINE n INTEGER DEFINE d DECIMAL(6,2) DEFINE c VARCHAR(200) DATABASE test1 EXECUTE IMMEDIATE "create function proc1( p1 integer )" || " returning decimal(6,2), varchar(200);" || " define p2 decimal(6,2);" || " define p3 varchar(200);" || " let p2 = p1 + 0.23;" || " let p3 = 'Value = ' || p1;" || " return p2, p3;" || " end function;" PREPARE stmt FROM "execute function proc1(?)" LET n = 111 EXECUTE stmt USING n INTO d, c DISPLAY d DISPLAY c END MAIN