this.parentForm.controls['question1'].valueChanges.subscribe(
(selectedValue) => {
console.log(selectedValue);
console.log(this.parentForm.get('question1').value);
}
);
我想创建一个触发器,当我在表中插入4个主题的值时,它将自动计算百分比并设置奖学金折扣,如果学生 60%然后设置一些卢比折扣,如果<强于> 80%比设定一些卢比折扣
答案 0 :(得分:0)
您需要编写简单的BEFORE INSERT
触发器。你甚至不需要光标。尝试以下触发器。
CREATE OR REPLACE TRIGGER stud_percent_disc
BEFORE INSERT
ON student
FOR EACH ROW
DECLARE
v_total student.total%type;
v_percent student.percentage%type;
v_discount student.discount%type;
BEGIN
-- calculate total
v_total := ( :new.s1 + :new.s2 + :new.s3 + :new.s4 );
-- calculate percentage
v_percent := ( v_total * 0.25 );
-- calculate discount value
if (v_percent >= 95) then
v_discount := 25000;
elsif (v_percent >= 90) then
v_discount := 20000;
elsif (v_percent >= 80) then
v_discount := 15000;
elsif (v_percent >= 75) then
v_discount := 10000;
else
v_discount := 0;
end if;
:new.total := v_total;
:new.percentage := v_percent;
:new.discount := v_discount;
END;
/
用户下面的插入语法:
insert into student(s1,s2,s3,s4,total,percentage,discount) values(88,88,88,88,0,0,0);