我已经创建了这个程序
create or replace procedure enrollstudent(
rno in STUDENTS.ROLL_NUMBER%type,
sname in STUDENTS.STUDENT_NAME%type,
cid in STUDENTS.COURSEID%type,
cfees in STUDENTS.FEES%type,
spercent in students.percentage%type
)as
discount number;
begin
discount := spercent*5;
cfees := cfees-discount;
insert into STUDENTS values(rno, sname, cid, cfees, spercent);
commit;
end;
适用于此表
CREATE TABLE STUDENTS(
ROLL_NUMBER NUMBER(20) NOT NULL,
STUDENT_NAME VARCHAR2(25) NOT NULL,
COURSEID NUMBER(20) NOT NULL,
FEES NUMBER(20) ,
PERCENTAGE NUMBER(20)
);
当我运行程序时,我有一个Procedure ENROLLSTUDENT compiled
并且它被创建但我在编译器日志中有以下错误
Error(8,1): PL/SQL: Statement ignored
Error(8,1): PLS-00363: expression 'CFEES' cannot be used as an assignment target
如果我尝试使用某些数据运行该过程,我可以使用PLS-00905: object [schema].ENROLLSTUDENT is invalid
答案 0 :(得分:2)
CFEES是一个IN参数。你无法改变它。创建一个局部变量,和 使用它,例如:
cfees2 NUMBER := cfees;
cfees2 := cfees2 - discount;
insert into STUDENTS values(rno, sname, cid, cfees2, spercent);
答案 1 :(得分:0)
您不需要定义和计算任何局部变量;你可以在cfees
语句中进行INSERT
的计算:
create or replace procedure enrollstudent(
rno in STUDENTS.ROLL_NUMBER%type,
sname in STUDENTS.STUDENT_NAME%type,
cid in STUDENTS.COURSEID%type,
cfees in STUDENTS.FEES%type,
spercent in students.percentage%type
)as
begin
insert into STUDENTS values(rno, sname, cid, cfees-spercent*5, spercent);
commit;
end;
/