我还没有用oracle编写很多存储过程。我阅读了一些tutotorials(例如:http://plsql-tutorial.com/plsql-procedures.htm),并试图在我看到后对我的sp进行建模,但我仍遇到错误。这里是一个小样本程序,错误:编写Oracle存储过程
create or replace
PROCEDURE TEST_SP()
BEGIN
insert into tablespace.tablename
select * from testtable;
END TEST_SP;
PLS-00103: Encountered the symbol ")" when expecting one of the following:
<an identifier> <a double-quoted delimited-identifier>
,我感到我很想念声明部分的印象,但我不明白,我应该要述说: -/
任何帮助将不胜感激。
随后从第一反应Justin的意见,现在得到不同的错误:
create or replace
PROCEDURE TEST_SP
AS
BEGIN
insert into tablespace.tablename (col1, col2)
select (col1, col2) from testtable;
END TEST_SP;
PLS-00103: Encountered the symbol "AS" when expecting one of the following:
. , @ in <an identifier> <a double-quoted delimited-identifier> partition subpartition
?你可以尝试使用SQL * Plus来确保你的工具没有问题(尤其是在可能存在未终止的SQL语句的GUI应用程序中)?如果你实际上在你的'INSERT'中使用了表空间的名称而不是模式的名字,你会得到一个ORA-00942错误。一般来说,尽管您发布的语法是有效的,但您不会在“SELECT”列中使用括号。 – 2012-04-20 18:30:53
你说得对,我正在使用模式名称而不是表空间。我正在使用sqldeveloper。 – 2012-04-20 22:13:03
您确定没有另一个SQL语句位于CREATE OR REPLACE PROCEDURE语句之上,但没有正确结束吗?你可以在SQL * Plus中运行CREATE OR REPLACE PROCEDURE语句吗? – 2012-04-20 22:14:25