如何将 :new 作为参数传递给 oracle 客户函数?
How to pass :new as parameter to oracle customer function?
我想将 :new 从触发器传递到我的自定义 oracle 函数,我尝试了所有方法但都失败了。
这是我的代码:
set serveroutput on;
create or replace function sum_evaluation_onerow(arow in t_attend_j301%rowtype)
return number
as
total number:=0;
begin
total:=trans_attend_type(arow.class12)+total;
total:=trans_attend_type(arow.class34)+total;
total:=trans_attend_type(arow.class56)+total;
total:=trans_attend_type(arow.class78)+total;
total:=trans_attend_type(arow.class90)+total;
dbms_output.put_line(total);
return total;
end;
/
create or replace trigger tg_insert_attend_j301
after insert on t_attend_j301
for each row
declare
total number;
myrow t_attend_j301%rowtype;
begin
--total:=sum_evaluation_onerow(:new);
myrow:=:new
update u_j301.t_stud_j301 set sum_evaluation=sum_evaluation where sno=:new.sno;
end;
/
我该怎么办?
单独分配 %ROWTYPE
的每个属性:
create or replace trigger tg_insert_attend_j301
after insert on t_attend_j301
for each row
declare
total number;
myrow t_attend_j301%rowtype;
begin
myrow.sno := :new.sno;
myrow.class12 := :new.class12;
myrow.class34 := :new.class34;
myrow.class56 := :new.class56;
myrow.class78 := :new.class78;
myrow.class90 := :new.class90;
total:=sum_evaluation_onerow(myrow);
update u_j301.t_stud_j301
set sum_evaluation=total
where sno=:new.sno;
end;
/
db<>fiddle here
我想将 :new 从触发器传递到我的自定义 oracle 函数,我尝试了所有方法但都失败了。 这是我的代码:
set serveroutput on;
create or replace function sum_evaluation_onerow(arow in t_attend_j301%rowtype)
return number
as
total number:=0;
begin
total:=trans_attend_type(arow.class12)+total;
total:=trans_attend_type(arow.class34)+total;
total:=trans_attend_type(arow.class56)+total;
total:=trans_attend_type(arow.class78)+total;
total:=trans_attend_type(arow.class90)+total;
dbms_output.put_line(total);
return total;
end;
/
create or replace trigger tg_insert_attend_j301
after insert on t_attend_j301
for each row
declare
total number;
myrow t_attend_j301%rowtype;
begin
--total:=sum_evaluation_onerow(:new);
myrow:=:new
update u_j301.t_stud_j301 set sum_evaluation=sum_evaluation where sno=:new.sno;
end;
/
我该怎么办?
单独分配 %ROWTYPE
的每个属性:
create or replace trigger tg_insert_attend_j301
after insert on t_attend_j301
for each row
declare
total number;
myrow t_attend_j301%rowtype;
begin
myrow.sno := :new.sno;
myrow.class12 := :new.class12;
myrow.class34 := :new.class34;
myrow.class56 := :new.class56;
myrow.class78 := :new.class78;
myrow.class90 := :new.class90;
total:=sum_evaluation_onerow(myrow);
update u_j301.t_stud_j301
set sum_evaluation=total
where sno=:new.sno;
end;
/
db<>fiddle here