Reputation: 511
I'm new to PL/SQL and I'd like to insert values into a global temp table using the following code:
CREATE GLOBAL TEMPORARY TABLE test_variable
(
only_datex TIMESTAMP(6) NULL,
only_datey TIMESTAMP(6) NULL
)
ON COMMIT PRESERVE ROWS;
DECLARE
x TIMESTAMP(6) := CURRENT_DATE;
y TIMESTAMP(6) := CURRENT_DATE - 1;
BEGIN
INSERT INTO test_variable VALUES(x,y);
END
SELECT * FROM test_variable;
After trying to select, I'm getting this error:
Upvotes: 1
Views: 1923
Reputation: 65363
you need a slash /
just after END;
DECLARE
x TIMESTAMP(6) := CURRENT_DATE;
y TIMESTAMP(6) := CURRENT_DATE - 1;
BEGIN
INSERT INTO test_variable VALUES(x,y);
END;/
SELECT * FROM test_variable;
Upvotes: 3
Reputation: 311863
You need to terminate the pl/sql block - you're missing the semicolon (;
) that goes with the end
and a slash (/
) to terminate the block:
CREATE GLOBAL TEMPORARY TABLE test_variable
(
only_datex TIMESTAMP(6) NULL,
only_datey TIMESTAMP(6) NULL
)
ON COMMIT PRESERVE ROWS;
DECLARE
x TIMESTAMP(6) := CURRENT_DATE;
y TIMESTAMP(6) := CURRENT_DATE - 1;
BEGIN
INSERT INTO test_variable VALUES(x,y);
END; -- Here
/
--^ And here
SELECT * FROM test_variable;
Upvotes: 3