我是PL / SQL的新手,我想使用以下代码将值插入到全局临时表中:
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;
答案 0 :(得分:3)
您需要终止pl / sql块 - 您缺少与;
一起使用的分号(end
)和斜杠(/
)来终止块:
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;
答案 1 :(得分:3)
在/
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;