【发布时间】:2015-03-10 09:47:04
【问题描述】:
Error(5,1): PLS-00103:
Encountered the symbol "CREATE" when expecting one of the following:
( begin case declare exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge
在我写的代码下面。
CREATE OR replace FUNCTION First_three_records
RETURN NUMBER AS
BEGIN
CREATE TEMPORARY TABLE temp_emp ON COMMIT DROP AS
SELECT *
FROM emp
WHERE deptno=20;
INSERT INTO tgt
SELECT *
FROM temp_emp;
END;
【问题讨论】:
-
你有什么问题?
-
dba.stackexchange.com/questions/37362/… -- 如果要创建临时表,则需要使用动态 SQL。
-
不要在函数中创建临时表。 Oracle 只有全局临时表,没有像其他 RDBMS 那样的本地临时表。