日期:2014-05-16  浏览次数:20937 次

Oracle游标声明报错
游标声明:
declare cursor cs_table_students is select id from table_students;student_id table_students.id%type;

报错信息:
ORA-06550: 第 4 行, 第 0 列: 
PLS-00103: 出现符号 "end-of-file"在需要下列之一时:
 begin function
   pragma procedure subtype type <an identifier>
   <a double-quoted delimited-identifier> current cursor delete
   exists prior

表格信息:
ID         NAME                 TELEPHONE
001        alice                136166
002        peter                136167
003        jack                 136168

请问错在哪里呢,书上和网上都是这么写的,为什么到我这就出错了?我想要知道为什么错了,不只是怎么写正确。

------解决方案--------------------
引用:
游标声明:
declare cursor cs_table_students is select id from table_students;student_id table_students.id%type;

报错信息:
ORA-06550: 第 4 行, 第 0 列: 
PLS-00103: 出现符号 "end-of-file"在需要下列之一时:
 begin function
   pragma procedure subtype type <an identifier>
   <a double-quoted delimited-identifier> current cursor delete
   exists prior

表格信息:
ID         NAME                 TELEPHONE
001        alice                136166
002        peter                136167
003        jack                 136168

请问错在哪里呢,书上和网上都是这么写的,为什么到我这就出错了?我想要知道为什么错了,不只是怎么写正确。

如果你代码不是很多请把你的代码全部贴出来看看,如果很多请贴关键部分
------解决方案--------------------
最近一点,定义变量的时候只能在DECLARE和BEGIN之间,否则也会报PLS-00103
------解决方案--------------------
楼主发帖为什么又不把代码格式化下呢
让别人去猜?
------解决方案--------------------
是不是哪里没写分号或者引号
------解决方案--------------------
都没有BEGIN END怎么编译过?
如果你要测试声明可以这样:

declare cursor cs_table_students is select id from table_students;student_id table_students.id%type;
begin
NULL;
END;

经测试,这样声明是完全没问题的