所以,我做了一些研究,从我能找到的类似问题,我无法解决我的特定问题。我遇到了可怕的,
错误(35,18):PLS-00103:遇到以下其中一项时遇到符号“文件结束”:(如果循环模式为空,则编译结束异常退出,如果循环模式为空,则为pragma raise返回选择更新时with<< continue close current delete fetch lock insert open rollback savepoint set sql execute commit for all merge pipe purge
一些修复方法是查看代码并找到任何遗漏的分号。我的特定代码的问题在于,如果没有声明作为存储过程和IN参数,代码就可以完美地运行。我正在采取一个有效的程序,只是试图能够在不对全新搜索进行硬编码的情况下改变搜索内容。那有意义吗?
这是代码:`
CREATE OR REPLACE PROCEDURE testProcedure(var_Name IN varchar2)
IS
BEGIN
DECLARE
var_Name newscores.name%TYPE;
var_courseNo newscores.courseNo%Type;
var_sectionNo newscores.sectionNo%Type;
var_average grade2.average%TYPE;
var_termscores gradepolicy.lettergrade%TYPE;
CURSOR AverageCursor is
SELECT distinct n.name, n.courseNo, n.sectionNo, g2.average, gp.lettergrade
from newscores n, grade2 g2, gradepolicy gp
where n.stuNo = g2.stuNo
and n.courseNo = g2.courseNo
and n.sectionNo = g2.sectionNo
and g2.average < gp.upper_bound
and g2.average > gp.low_bound
and n.name = 'Randy Ballard'
and gp.classNo = g2.courseNo
and gp.sectionNo = g2.sectionNo;
BEGIN
OPEN AverageCursor;
LOOP
FETCH AverageCursor
INTO var_Name, var_courseNo, var_SectionNo, var_average, var_termscore;
Exit when AverageCursor%NOTFOUND;
dbms_output.put_line('Full Name'||' '||var_Name);
dbms_output.put_line('Full Name'||' '||var_courseNo);
dbms_output.put_line('Full Name'||' '||var_sectionNo);
dbms_output.put_line('Full Name'||' '||var_average);
dbms_output.put_line('Full Name'||' '||var_termscore);
END LOOP;
END testProcedure;
/
`
答案 0 :(得分:0)
DECLARE
关键字和额外BEGIN
导致您的错误。试试这个:
CREATE OR REPLACE PROCEDURE testProcedure(p_name IN VARCHAR2)
IS
var_Name newscores.name%TYPE;
var_courseNo newscores.courseNo%Type;
var_sectionNo newscores.sectionNo%Type;
var_average grade2.average%TYPE;
var_termscores gradepolicy.lettergrade%TYPE;
CURSOR AverageCursor is
SELECT distinct n.name, n.courseNo, n.sectionNo, g2.average, gp.lettergrade
from newscores n, grade2 g2, gradepolicy gp
where n.stuNo = g2.stuNo
and n.courseNo = g2.courseNo
and n.sectionNo = g2.sectionNo
and g2.average < gp.upper_bound
and g2.average > gp.low_bound
and n.name = p_name
and gp.classNo = g2.courseNo
and gp.sectionNo = g2.sectionNo;
BEGIN
OPEN AverageCursor;
LOOP
FETCH AverageCursor
INTO var_Name, var_courseNo, var_SectionNo, var_average, var_termscore;
Exit when AverageCursor%NOTFOUND;
dbms_output.put_line('Full Name'||' '||var_Name);
dbms_output.put_line('Full Name'||' '||var_courseNo);
dbms_output.put_line('Full Name'||' '||var_sectionNo);
dbms_output.put_line('Full Name'||' '||var_average);
dbms_output.put_line('Full Name'||' '||var_termscore);
END LOOP;
END testProcedure;
/
通常,您在IS
和BEGIN
关键字之间声明变量。