Create TEMPORARY Table using dynamic SQL
Posted by:
John Noble
Date: October 28, 2022 03:44PM
Hi folks,
I am trying to create a Temporary table using variables
If I use:
CREATE TEMPORARY TABLE tempTable SELECT * FROM myTable;
it will work fine,
Except, I don't know the name of the table in advance. That is passed into the sproc.
So I need to use something more dynamic like
SET @vTableName= CONCAT("tableName", variableName);
SET @vSQL = CONCAT("SELECT * FROM ", @vTableName);
CREATE TEMPORARY TABLE tempTable @vSQL;
Except this wont compile.
Is there a way around this?
Thanks,
JOhn
Subject
Views
Written By
Posted
Create TEMPORARY Table using dynamic SQL
106
October 28, 2022 03:44PM
39
December 20, 2022 04:40AM
Sorry, only registered users may post in this forum.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.