Teach you to start script trace stored procedures in Oracle

Source: Internet
Author: User
Tags goto

A script to start and set up a trace example we can use script to trace stored procedures, of course, to understand the specific syntax of these stored procedures and parameters of the meaning of these syntax and parameter meaning please check online Help. Take a look at the following example:

/*******************************************/
/* Created by:sql Profiler * *
* DATE:2004/06/19 16:50:05 * *
/*******************************************/
--Create a Queue
DECLARE @rc int
DECLARE @TraceID int
DECLARE @maxfilesize bigint
Set @maxfilesize = 5

--Please replace the text insertfilenamehere and an appropriate
--filename prefixed by a path, e.g, c:\MyFolder\MyTrace. The. trc extension
---would be appended to the filename automatically. If you are are writing from
--Remote server to local drive, "use UNC path and make sure server has
--Write access to your network share

exec @rc = sp_trace_create @TraceID output, 0, N ' c:\test ', @maxfilesize, NULL
if (@rc!= 0) Goto Error

--Client side File and Table cannot be scripted
--writing to a table isn't supported through the SP ' s
--Set The events
DECLARE @on bit
Set @on = 1
exec sp_trace_setevent @TraceID, 1, @on
exec sp_trace_setevent @TraceID, @on
exec sp_trace_setevent @TraceID, @on

--Set The Filters
DECLARE @intfilter int
DECLARE @bigintfilter bigint
exec sp_trace_setfilter @TraceID, 0, 7, N ' SQL Profiler '
Set @intfilter = 100
exec sp_trace_setfilter @TraceID, 0, 4, @intfilter
Set @intfilter = 1
EXEC sp_trace_setfilter @TraceID, 1, 0, @intfilter
EXEC sp_trace_setfilter @TraceID, 1, 6, N ' pubs '

--Set The trace status to start
exec sp_trace_setstatus @TraceID, 1
--Display trace ID for future references
Select Traceid= @TraceID
Goto Finish

Error
Select Errorcode= @rc
Finish
Go

Related Article

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.