Please find the code for creating a temporary table and access it in UDF functions.
While we do this we obtain a compile time error stating "A declared temporary table cannot be used in the given context."
Can we create a temporary table in udf ?
While we do this we obtain a compile time error stating "A declared temporary table cannot be used in the given context."
Code:
CODE:
DECLARE GLOBAL TEMPORARY TABLE
SESSION.TEMP (id INT, data VARCHAR(10))
ON COMMIT PRESERVE ROWS;
----------------------------- Commands Entered ------------------------------
CREATE FUNCTION fn_DocumentCount2 (v_GroupID CHAR(16) FOR BIT DATA )
RETURNS INTEGER
LANGUAGE SQL
BEGIN ATOMIC
DECLARE v_documentcount INTEGER;
delete from SESSION.TEMP;
RETURN 10;
END!
ERROR:
SQL0526N The requested function does not apply to declared temporary tables.
Explanation:
A declared temporary table cannot be used in the given context.
Comment