The DECLARE
keyword and extra BEGIN
are causing your error. Try this:
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;
/
Normally you declare your variables between the IS
and the BEGIN
keywords.