1 2 3 /*
4 ** This procedure deletes Backup objects backed up at Storage Manager.
5 ** It sends bs_deletesmobj RPC to the Backup Server, passing all the
6 ** parameters to the stored procedure as it is. The parsing of all the
7 ** options is done by the Backup Server. The actual Query operation is
8 ** performed by Backup Server using the syb_deleteobj() API call of the
9 ** API interface supplied as an argument.
10 **
11 ** This can be issued only by users with SA role or oper_role.
12 */13 14 /*
15 ** Messages for "sp_deletesmobj"
16 **
17 ** 17260, "Can't run %1! from within a transaction."
18 ** 18255, "%1! cannot be NULL."
19 ** 19980, "You are not authorized to execute this stored procedure.
20 ** Only the System Administrator (SA) or a user with oper_role
21 ** authorization can execute this stored procedure."
22 **
23 */24 25 createproceduresp_deletesmobj26 @sm_api_name varchar(30)=NULL,/* SM Interface Stream name*/27 @server_name varchar(30)=NULL,/* Server Instance name */28 @database_name varchar(30)=NULL,/* Database name */29 @object_name varchar(255)=NULL,/* Archive object name */30 @dump_type varchar(30)=NULL,/* Database dump type */31 @until_time varchar(30)=NULL,/* Until point in time */32 @bs_name varchar(30)=NULL/* Backup Server name */33 as34 35 begin36 37 declare@status int /* RPC status */38 declare@bs_rpc varchar(255)/* RPC site and proc name */39 40 if @@trancount > 0
41 begin42 /* 17260, "Can't run %1! from within a transaction." */43 raiserror 17260, "sp_deletesmobj"
44 return(1)45 end46 47 48 /*
49 ** Only the accounts with either SA role or oper_role can execute this
50 ** procedure.
51 **
52 ** If user does not have either the sa role or the oper_role, we cannot
53 ** continue any further.
54 */55 if((proc_role("oper_role")= 0)and(proc_role("sa_role")= 0))56 begin57 raiserror 19980
58 return(1)59 end60 61 /*
62 ** Check for mandatory parameters supplied.
63 **
64 */65 if(@sm_api_nameisNULL)66 begin67 raiserror 18255, "Storage Manager API module name"
68 return(1)69 end70 71 if(@server_nameisNULL)72 begin73 raiserror 18255, "Server name"
74 return(1)75 end76 77 /* Select SYB_BACKUP as default Backup Server */78 if(@bs_nameisNULL)79 begin80 select@bs_rpc= 'SYB_BACKUP...bs_deletesmobj'
81 end82 else83 begin84 select@bs_rpc=@bs_name+ '...bs_deletesmobj'
85 end86 87 /* Issue bs_deletesmobj RPC to Backup Server */88 exec@status=@bs_rpc@sm_api_name,@server_name,@database_name,@object_name,@dump_type,@until_time,@bs_name89 90 return(@status)91 92 end93
exec sp_procxmode 'sp_deletesmobj', 'AnyMode'
go
Grant Execute on sp_deletesmobj to public
go