specification
. 1 Create or Replace procedure_name 2 ( . 3 - Parameter: argument, named according to the type of parameters, such as the number is an _..., date _... is AD . 4 ad_data_date in DATE, . 5 - table name column the parameter type name is defined. . 6 p_id Table .id % type . 7 ) . 8 iS . 9 - variables: variable, number _... is VN 10 the begin . 11 - service processing 12 is the commit ; 13 is 14 Exception 15 When Othersthe then 16 ai_code: = SQLCODE; - Oracle's own function, the sequence returns Oracle error . 17 ai_desc: = substr (SQLERRM, . 1 , 1000 ); - returns an error message 18 is - error processing, general write log . 19 ROLLBACK ; 20 is End ; 21 is End ;
Combined package, the calculation control procedure, log_procedure use
. 1 Create or Replace Package body pkg_name IS 2 - Procedure_1 . 3 prc_log . 4 ( . 5 ac_prc_name in VARCHAR2 , - procedure name . 6 ad_bgn_date in DATE, - the start time . 7 ad_end_date in DATE, - end time . 8 ac_res_code in VARCHAR2 , - result Code 9 ac_res_desc in VARCHAR2 ,- Results Description 10 ac_remark in VARCHAR2 - Note . 11 ) 12 is IS 13 is the begin 14 INSERT INTO log_table (Columns) values (...); 15 the commit ; 16 . 17 Exception 18 is When Others the then . 19 ROLLBACK ; 20 is End ; 21 is 22 is - - procedure_2 23 prc_name 24- ( - parameter 25 an_data_date in Number , - data time 26 is an_code OUT Number , - the results of the code 27 av_desc OUT VARCHAR2 - Results of Description 28 ) IS 29 - variable 30 vd_bgn_date DATE; 31 is vd_end_date DATE; 32 the begin 33 is vd_bgn_date: = SYSDATE; 34 is - business process 35 36 an_code: = 0 ; 37 [ av_desc: = '执行成功'; 38 select sysdate into vd_end_date from dual; 39 40 --写日志 41 prc_log(prc_name,vd_bgn_date,vd_end_date,an_code,av_desc,'备注'); 42 commit; 43 44 exception 45 when others then 46 --sqlcode 47 an_code := sqlcode; 48 --sqlerrm 49 av_desc := substr(sqlerrm,. 1 , 1000 ); 50 vd_end_date: = SYSDATE; 51 is ROLLBACK ; 52 is - write log 53 is prc_log (prc_name, vd_bgn_date, vd_end_date, an_code, av_desc, ' Remarks ' ); 54 is the commit ; 55 End ; 56 is 57 is - Calculation Control 58 Procedure prc_ctl 59 ( 60 ad_date in DATE, 61 is an_code OUT Number , 62 is av_desc OUTVARCHAR2 63 is ) 64 IS 65 - variable 66 vd_data_date VARCHAR2 ; - data time, conditional execution 67 vd_bgn_date DATE; 68 vd_end_date DATE; 69 the begin 70 vd_bgn_date: = SYSDATE; 71 is IF ... the then 72 - service processing, call stored procedure 73 is prc_name (vd_data_date); 74 the else ... 75 End IF ; 76 77 an_code: = 0 ; 78 av_desc := '执行成功'; 79 vd_end_date := sysdate; 80 81 --log 82 prc_log('prc_ctl',vd_bgn_date,vd_end_date,an_code,av_desc,'备注'); 83 commit; 84 85 exception 86 when others then 87 an_code := sqlcode; 88 av_desc := substr(sqlerrm,1,1000); 89 vd_end_date := sysdate; 90 rollback; 91 --log 92 prc_log('prc_ctl',vd_bgn_date,vd_end_date,an_code,av_desc,'备注'); 93 commit; 94 end; 95 end;