1. Create a trigger:
-- If the licensing time of a yellow card is less than the licensing time of an alarm,
-- Exchange their card placement time.
Create or replace trigger after_punish_update_time
After insert on winf_sv_punish
For each row
Declare
Param_id varchar2 (100); -- card ID
Param_breakrule varchar2 (100);-violation of rules
Param_punishresult varchar2 (2); -- card placement result (warning, exception, yellow card, red card)
Param_sblsh varchar2 (100); -- apply for the serial number
Param_yujingpunishid varchar2 (2); -- ID of the card placement warning
Param_smalldate date; -- the card placement time of the warning.
Param_bigdate date; -- the card placement time of the yellow card
Begin
Param_id: =: New. ID;
Param_breakrule: =: New. break_rule;
Param_punishresult: =: New. punish_result;
Param_sblsh: =: New. sblsh;
Param_bigdate: =: New. break_time;
-- Query the Alert ID of a rule for this service, and the alert placement time
Select P. ID, P. break_time into param_yujingpunishid, param_smalldate from winf_sv_punish P where P. break_rule = (
Select R. ID from winf_sv_rule R
Left join winf_sv_supervisepoint SP on R. supervise_point = sp. ID
Where R. supervise_point = (
Select R. supervise_point from winf_sv_rule R where R. ID = param_breakrule
) And R. rule_punish = '1') and P. sblsh = param_sblsh and P. punish_result = '1 ';
-- Set the rule card to a yellow card
If param_punishresult = '2' and param_bigdate <param_smalldate then
-- Define a cursor to check the verification director of the department. If yes, the system sends the cursor (the status is 0). If no cursor is displayed, it is saved to the task to be submitted (the status is-1)
Dbms_output.put_line ('bid: '| param_sblsh | 'yellow card id' | param_id | 'Warning id' | param_yujingpunishid );
-- Exchange card placement time
Update winf_sv_punish P1 set p1.break _ time = param_smalldate where p1.id = param_id;
Update winf_sv_punish P2 set p2.break _ time = param_bigdate where p2.id = param_yujingpunishid;
End if;
Exception
When no_data_found then NULL;
End after_punish_update_time;
2. Run the test statement and report the following error:
-- Created on 2014/10/16 by laiwenhua
Declare
-- Local variables here
I integer;
Begin
-- Test statements here
Insert into winf_sv_punish
(ID,
Break_rule,
Break_time,
Sblsh,
Punish_level,
Punish_result,
Operate_type,
Punish_userid,
Punish_explain,
Ishandle,
Punish_type,
Node_id,
Send_status,
Send_lead_status,
Is_confirm,
Confirm_time)
Values
('81af91db3c1b49a6a0f62b522275007a ',
'2f105e0797f84ea5b0cceb6a3f43b7fa ',
To_date ('1970-10-16 23:07:50 ', 'yyyy-mm-dd hh24: MI: ss '),
'Yc-100 ',
'1 ',
'2 ',
'2 ',
'3d12f197c5a04f2a8617d591acbf6ea9 ',
'Your business is responsible for applying for a sales license for the tobacco monopoly ,',
'2 ',
'1 ',
'E939179c76c74be5b29eca958a3cd67e ',
'2 ',
'2 ',
'1 ',
To_date ('2017-10-16 23:07:50 ', 'yyyy-mm-dd hh24: MI: ss '));
-- (String)
End;
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/4C/8D/wKiom1Q_5byzEiH_AAFI71uNRB8197.jpg "Title =" bu.png "alt =" wkiom1q_5byzeih_aafi71unrb8197.jpg "/>
3. Solution: add an autonomous transaction.
Add Pragma autonomous_transaction after declare;
The trigger of Table XXX is changed and cannot read it.