我试图按照http://dba-oracle.com/t_pl_sql_plsql_select_into_clause.htm的例子
但是当我这样做的时候
create or replace PROCEDURE age
is
declare
info movie%rowtype;
BEGIN
dbms_output.enable();
select * into info from movie where mo_id=1;
dbms_output.put_line('The name of the product is ' || info.mo_id);
END age;
/
它给出了一些错误:
错误(4,1):PLS-00103:遇到以下其中一项时遇到符号"DECLARE":begin function pragma procedure子类型当前游标删除存在于外部语言之前符号"begin"替换"DECLARE"继续 .
和
错误(14,8):PLS-00103:遇到以下其中一项时遇到符号"end-of-file" :(如果循环mod为空pragma,则返回选择更新,同时使用<< continue close current delete fetch lock) insert open rollback savepoint set sql execute commit forall merge pipe purge
它出什么问题了?
2 回答
您的代码中有几件事要看一下:首先 . 正如@Polppan已经提到的,从存储过程中删除
DECLARE
关键字 . 没有必要 . 但是,当您编写匿名PL / SQL块时,您将需要它 . 第二 . 如果你在程序中使用dbms_output.enable()
然后显示行,我假设你正在使用sql * plus,你将需要调用dbms_output.get_lines()
否则它不会给你想要的结果 . 所以为了简化那个使用set serveroutput on
命令的sql * plus来启用输出 . 并且不要混用dbms_output.enable()
和setserveroutput on
- 使用它们中的任何一个 . 不是都 . 这是一个例子:尝试使用以下内容,您不需要在过程中声明 .
并执行您可以执行的过程