/*
根據sendTab的SendTime定制作業
並且在該作業完成時
create table sendTab(ID int identity(
create table accepteTab(ID int identity(
go
create proc p_JobSet
@id int
@is_delete bit=
as
declare @dbname sysname
select @jobname=
from sendTab where id=@id
if exists(select
exec msdb
if @is_delete=
exec msdb
declare @sql varchar(
select @sql=
select name
+cast(@id as varchar)
exec msdb
@step_name =
@subsystem =
@database_name=@dbname
@command = @sql
@retry_attempts =
@retry_interval =
EXEC msdb
@name =
@enabled =
@freq_type =
@active_start_date = @date
@active_start_time = @time
EXEC msdb
@job_name = @jobname
@server_name = N
go
create trigger tr_insert_update on sendTab
for insert
as
declare @id int
declare tb cursor local for select id from inserted
open tb
fetch next from tb into @id
while @@fetch_status=
begin
exec p_JobSet @id
fetch next from tb into @id
end
close tb
deallocate tb
go
create trigger tr_delete on sendTab
for delete
as
declare @id int
declare tb cursor local for select id from deleted
open tb
fetch next from tb into @id
while @@fetch_status=
begin
exec p_JobSet @id
fetch next from tb into @id
end
close tb
deallocate tb
go
insert sendTab
select
union all select
union all select
update sendTab set name=
where id=
delete sendtab where id=
go
drop table sendTab
drop proc p_JobSet
From:http://tw.wingwit.com/Article/program/Oracle/201311/17542.html