The Create or replace function f_borrowed_num (v_readerid number)
Return the number
As
V_num number;
The Begin
Select count (*) into v_num from reader, borrow the where reader. Readerid=v_readerid and reader. Readerid=borrow. Readerid;
Return v_num;
The End;
- using a custom function to write a as long as there is change in the borrow list is updated rest_borrow_num trigger
The create or replace the trigger tr_update_borrow
After the update or delete or insert on borrow
For each row
Declare
V_rule rule % rowtype;
Cursor cur_rule is (select readerid from reader);
The begin
Select * into v_rule from rule;
For v_readerid cur_rule in loop
The update reader set rest_borrow_num=v_rule. Num - f_borrowed_num (v_readerid)
Where v_readerid=: old. Readerid and reader. Readertype=v_rule. Readertype;
end loop;
The End;
When an error: error (270, 21) : PLS - 00382: expression type error
Bosses told me the reason and how to correct!!!!!! thank you
CodePudding user response:
Select * into v_rule from rule;This is to be found out more line, how to do?
CodePudding user response:
Well, the rule is more than just a, don't use a double cursor cycle, this I do not understand; TestThe create or replace the trigger tr_update_borrow
After the update or delete or insert on borrow
For each row
Declare
Cursor cur_reader is the select readerid from reader;
Cursor cur_rule is the select * from rule;
The begin
For v_readerid cur_reader in loop
For v_rule cur_rule in loop
The update reader set rest_borrow_num=v_rule. Num - f_borrowed_num (v_readerid)
Where v_readerid=: old. Readerid and reader. Readertype=v_rule. Readertype;
End loop cur_reader;
End loop cur_rule;
The End;
But it's still the same error,