您现在的位置: 万盛学电脑网 >> 程序编程 >> 数据库 >> oracle教程 >> 正文

教你在Oracle中启动脚本跟踪存储过程

作者:佚名    责任编辑:admin    更新时间:2022-06-22

一、用脚本启动并设置跟踪的示例 我们可以用脚本进行跟踪存储过程,当然要了解这些存储过程的具体语法和参数的含义,至于这些语法和参数含义请查询联机帮助。下面请看一实例:

/*******************************************/
/* 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, with an appropriate
-- filename prefixed by a path, e.g., c:\MyFolder\MyTrace. The .trc extension
-- will be appended to the filename automatically. If you are writing from
-- remote server to local drive, please 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 is not supported through the SP's
-- Set the events
declare @on bit
set @on = 1
exec sp_trace_setevent @TraceID, 12, 1, @on
exec sp_trace_setevent @TraceID, 12, 12, @on
exec sp_trace_setevent @TraceID, 12, 14, @on

-- Set the Filters
declare @intfilter int
declare @bigintfilter bigint
exec sp_trace_setfilter @TraceID, 10, 0, 7, N'SQL Profiler'
set @intfilter = 100
exec sp_trace_setfilter @TraceID, 22, 0, 4, @intfilter
set @intfilter = 1
exec sp_trace_setfilter @TraceID, 23, 1, 0, @intfilter
exec sp_trace_setfilter @TraceID, 35, 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

  • 共2页:
  • 上一页
  • 1
  • 2
  • 下一页