Bruno Almeida
9 years ago
Hello friends,
DB2 V10.1 LUW
I would like to create a stored procedure using a table as argument. This table will be use as a global temporary table name, as follow:
***@renata-molinaro:$ db2 -tvf p.sql
drop procedure INIT_TEMP_TABLE
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0204N "DB2INST1.INIT_TEMP_TABLE" is an undefined name. SQLSTATE=42704
CREATE PROCEDURE INIT_TEMP_TABLE(in TABNAME)
BEGIN
DECLARE GLOBAL TEMPORARY TABLE TABNAME ( MACHINE_ID VARCHAR(24) ) ON COMMIT PRESERVE ROWS IN USER_TEMP;--
CREATE INDEX SESSION.IDXMID ON TABNAME (MACHINE_ID ASC) ALLOW REVERSE SCANS;--
END
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0204N "TABNAME" is an undefined name. LINE NUMBER=1. SQ/LSTATE=42704
Yes, I know that there isn't a table called TABNAME in my DB.
My idea is: call apr.init_temp_table (SESSION.TMP_TABLE_ABC)
My application build the temp table's name aleatory, by concurrent problems.
Is there a way to solve this issue?
Thanks in advance.
-B
DB2 V10.1 LUW
I would like to create a stored procedure using a table as argument. This table will be use as a global temporary table name, as follow:
***@renata-molinaro:$ db2 -tvf p.sql
drop procedure INIT_TEMP_TABLE
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0204N "DB2INST1.INIT_TEMP_TABLE" is an undefined name. SQLSTATE=42704
CREATE PROCEDURE INIT_TEMP_TABLE(in TABNAME)
BEGIN
DECLARE GLOBAL TEMPORARY TABLE TABNAME ( MACHINE_ID VARCHAR(24) ) ON COMMIT PRESERVE ROWS IN USER_TEMP;--
CREATE INDEX SESSION.IDXMID ON TABNAME (MACHINE_ID ASC) ALLOW REVERSE SCANS;--
END
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0204N "TABNAME" is an undefined name. LINE NUMBER=1. SQ/LSTATE=42704
Yes, I know that there isn't a table called TABNAME in my DB.
My idea is: call apr.init_temp_table (SESSION.TMP_TABLE_ABC)
My application build the temp table's name aleatory, by concurrent problems.
Is there a way to solve this issue?
Thanks in advance.
-B