我正在尝试执行以下 PL/SQL 查询,但无法执行。SQL 命令提示符在最后一行显示错误
错误:
ENCOUNTERED THE SYMBOL ";" WHEN EXPECTING ONE OF THE FOLLOWING : IF.
代码:
SET SERVEROUTPUT ON
SET VERIFY OFF
DECLARE
v_reg registration%ROWTYPE;
v_totalscore NUMBER;
BEGIN
v_reg.registrationid :='®istrationid';
v_reg.studentid := &studentid;
v_reg.courseid := '&courseid';
v_reg.projectscore := &projectscore;
v_reg.assignmentscore := &assgnscore;
v_reg.internalscore := &internalscore;
v_reg.semesterscore := &semesterscore;
IF NOT v_reg.projectscore BETWEEN 0 AND 20 THEN
DBMS_OUTPUT.PUT_LINE('Invalid project score');
ELSIF NOT v_reg.assignmentscore BETWEEN 0 AND 10 THEN
DBMS_OUTPUT.PUT_LINE('Invalid assignment score');
ELSIF NOT v_reg.internalscore BETWEEN 0 AND 20 THEN
DBMS_OUTPUT.PUT_LINE('Invalid internal score');
ELSIF NOT v_reg.semesterscore BETWEEN 0 AND 50 THEN
DBMS_OUTPUT.PUT_LINE('Invalid semester score');
ELSE
v_totalscore:=v_reg.projectscore+v_reg.assignmentscore+v_reg.internalscore+v_reg.semesterscore;
DBMS_OUTPUT.PUT_LINE('Student id'||v_reg.studentid);
DBMS_OUTPUT.PUT_LINE('Course id : '||v_reg.courseid);
DBMS_OUTPUT.PUT_LINE('Total score : '||v_totalscore);
END IF;
END;
以下是上述代码引用的注册表的表结构。
CREATE TABLE registration (
registrationid NUMBER CONSTRAINT pk_registration_registrationid PRIMARY KEY,
studentid NUMBER CONSTRAINT fk_registration_studentid REFERENCES student(studentid),
courseid VARCHAR2(4) CONSTRAINT fk_registraiton_courseid REFERENCES course(courseid),
projectscore NUMBER(3),
assignmentscore NUMBER(3),
internalscore NUMBER(3),
semesterscore NUMBER(3),
grade Varchar2(2)
);
我是 SQL 新手并使用命令提示符运行 Sql,我没有输入创建表的代码,这是可能的原因吗?