PL/SQL 程序未编译
PL/SQL procedure not compiling
我有一个未编译的 PL/SQL 程序。错误是:
Error(3,7): PLS-00103: Encountered the symbol "INTO" 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 The symbol "INTO" was ignored.
Error(8,1): PLS-00428: an INTO clause is expected in this SELECT statement
.
我的代码:
CREATE OR REPLACE PROCEDURE findvisitsandlaborcosts
as
begin
select * from SI.customer;
end;
/
我用谷歌搜索了一个在线语法检查器,它说第一行有错误。但是哪里?!?这似乎是正确的。我已经用谷歌搜索了声明过程的语法,并且我已经交叉检查了很多次。这一定是我忽略的简单事情......
在 PLSQL 代码中,您需要一个占位符来保存 SELECT 查询的结果。由于 PLSQL 引擎需要 SELECT 语句中的 INTO 子句。
首先,您可以 select 一组列并将它们的值分配给局部变量。
你的代码应该是这样的-
CREATE OR REPLACE PROCEDURE findvisitsandlaborcosts
as
v_column1 SI.customer.column1%type;
v_column2 SI.customer.column2%type;
begin
select column1, column2 into v_column1, v_column2 from SI.customer;
end;
/
注意 - 您需要在 运行 这段代码之前用实际的列名替换 column1 和 column2。
如果您希望结果显示在过程的调用者上,那么您将定义一个 out 参数并在过程外部打印记录
CREATE OR REPLACE PROCEDURE findvisitsandlaborcosts(x out sys_refcursor)
as
begin
open x for
select * from dual;
end;
/
--Note this block of code needs to be run in sqlci or sqldeveloper
define m ref cursor;
exec findvisitsandlaborcosts(:x);
print x;
Oracle 12c 支持隐式 return 结果
看看这个link
https://oracle-base.com/articles/12c/implicit-statement-results-12cr1
我有一个未编译的 PL/SQL 程序。错误是:
Error(3,7): PLS-00103: Encountered the symbol "INTO" 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 The symbol "INTO" was ignored.
Error(8,1): PLS-00428: an INTO clause is expected in this SELECT statement
.
我的代码:
CREATE OR REPLACE PROCEDURE findvisitsandlaborcosts
as
begin
select * from SI.customer;
end;
/
我用谷歌搜索了一个在线语法检查器,它说第一行有错误。但是哪里?!?这似乎是正确的。我已经用谷歌搜索了声明过程的语法,并且我已经交叉检查了很多次。这一定是我忽略的简单事情......
在 PLSQL 代码中,您需要一个占位符来保存 SELECT 查询的结果。由于 PLSQL 引擎需要 SELECT 语句中的 INTO 子句。
首先,您可以 select 一组列并将它们的值分配给局部变量。
你的代码应该是这样的-
CREATE OR REPLACE PROCEDURE findvisitsandlaborcosts
as
v_column1 SI.customer.column1%type;
v_column2 SI.customer.column2%type;
begin
select column1, column2 into v_column1, v_column2 from SI.customer;
end;
/
注意 - 您需要在 运行 这段代码之前用实际的列名替换 column1 和 column2。
如果您希望结果显示在过程的调用者上,那么您将定义一个 out 参数并在过程外部打印记录
CREATE OR REPLACE PROCEDURE findvisitsandlaborcosts(x out sys_refcursor)
as
begin
open x for
select * from dual;
end;
/
--Note this block of code needs to be run in sqlci or sqldeveloper
define m ref cursor;
exec findvisitsandlaborcosts(:x);
print x;
Oracle 12c 支持隐式 return 结果
看看这个link https://oracle-base.com/articles/12c/implicit-statement-results-12cr1