Oracle Stored Procedure Code logging

Source: Internet
Author: User

prompt Create a function F_getprocname
CREATE ORREPLACEFUNCTION f_getprocname RETURN VARCHAR2
-- gets the name and caller of the function or stored procedure itself
is
L_ownerVARCHAR2( 30);
L_nameVARCHAR2( 30);
L_linenonumber;
L_typeVARCHAR2( 30);
BEGIN
Owa_util.Who_called_me(l_owner , l_name< Span style= "Color:navy" > , L_lineno , L_type );
RETURN L_ Owner | | '. ' | | L_name ;
end;
/

promptis in the execution Create a tableT_proc_logs
Declare
???? V_count Number:=0;
???? V_tb_namevarchar2( 1000):=' T_proc_logs ';
begin
????SELECTCount(*) intoV_count fromUser_objectsWHEREobject_name=UPPER( V_tb_name);
????ifV_count>0 Then
????????ExecuteImmediate' Drop table '||UPPER( V_tb_name);
????Endif;
end;
/
CreateTableT_proc_logs
(
log_idnumber( 10)default0 notnull,
Proc_mcVARCHAR2( 100)default‘ ‘ notnull,
TITLEVARCHAR2( 4000)default‘ ‘ notnull,
CONTENTVARCHAR2( 4000)default‘ ‘ not null
Log_type varchar2 ( 10< Span style= "Color:navy" > ) default " not null
Log_time DATE
Span style= "Color:navy" > );

promptis in the execution Create a sequenceseq_log_id
Declare
???? V_countnumber;
???? V_sequence_namevarchar2( 1000):=' seq_log_id ';
begin
SelectCount(*) intoV_count fromUser_sequences AwhereA.Sequence_name=Upper( V_sequence_name);
if(V_count=0) Then
ExecuteImmediate' Create sequence '||V_sequence_name | |
' increment by 1 start with 1 ' | |
' maxvalue 2100000000 minvalue 1 ' | |
' cycle nocache Noorder ' ;
end < Span style= "Color:blue" > if
end;
/

?

?

?

?

?

?

?

Oracle Stored Procedure Code logging

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.