I'm new to Oracle scripting and I'm having problems with inserting data to a global temporary table. Here's the script I created in Toad:
SET SERVEROUTPUT ON;
DECLARE
tempTwwIDExist NUMBER;
v_sql LONG;
BEGIN
SELECT COUNT(*) INTO tempTwwIDExist FROM USER_TABLES WHERE table_name = UPPER('tempTwwID');
DBMS_OUTPUT.PUT_LINE(tempTwwIDExist);
IF (tempTwwIDExist > 0) THEN
BEGIN
EXECUTE IMMEDIATE 'TRUNCATE TABLE tempTwwID';
EXECUTE IMMEDIATE 'DROP TABLE tempTwwID';
END;
END IF;
EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE tempTwwID (id NUMBER NOT NULL, SITEID NUMBER) ON COMMIT DELETE ROWS';
EXECUTE IMMEDIATE 'INSERT INTO tempTwwID (id, SITEID) VALUES (1,123)';
END;
/
However, when I run a SELECT statement to get all data from tempTwwID, now rows are returned despite the INSERT statement this script runs using EXECUTE IMMEDIATE (last line of code before END;).
I hope you can help me with this. Thanks in advance.