1 2 3 /*
4 ** This procedure performs queries Backup objects backed up at Storage Manager.
5 ** It sends bs_querysmobj 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_queryobj() 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_querysmobj"
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_querysmobj26 @sm_api_name varchar(30)=NULL,/* SM Interface Stream name*/27 @output_fname varchar(255)=NULL,/* Output filename path */28 @server_name varchar(30)=NULL,/* Server Instance name */29 @database_name varchar(30)=NULL,/* Database name */30 @object_name varchar(255)=NULL,/* Archive object name */31 @dump_type varchar(30)=NULL,/* Database dump type */32 @until_time varchar(30)=NULL,/* Until point in time */33 @bs_name varchar(30)=NULL/* Backup Server name */34 as35 36 begin37 38 declare@status int /* RPC status */39 declare@bs_rpc varchar(255)/* RPC site and proc name */40 41 if @@trancount > 0
42 begin43 /* 17260, "Can't run %1! from within a transaction." */44 raiserror 17260, "sp_querysmobj"
45 return(1)46 end47 48 49 /*
50 ** Only the accounts with either SA role or oper_role can execute this
51 ** procedure.
52 **
53 ** If user does not have either the sa role or the oper_role, we cannot
54 ** continue any further.
55 */56 if((proc_role("oper_role")= 0)and(proc_role("sa_role")= 0))57 begin58 raiserror 19980
59 return(1)60 end61 62 /*
63 ** Check for mandatory parameters supplied.
64 **
65 */66 if(@sm_api_nameisNULL)67 begin68 raiserror 18255, "Storage Manager API module name"
69 return(1)70 end71 72 if(@output_fnameisNULL)73 begin74 raiserror 18255, "Query output filename"
75 return(1)76 end77 78 if(@server_nameisNULL)79 begin80 raiserror 18255, "Server name"
81 return(1)82 end83 84 /* Select SYB_BACKUP as default Backup Server */85 if(@bs_nameisNULL)86 begin87 select@bs_rpc= 'SYB_BACKUP...bs_querysmobj'
88 end89 else90 begin91 select@bs_rpc=@bs_name+ '...bs_querysmobj'
92 end93 94 exec@status=@bs_rpc@sm_api_name,@output_fname,@server_name,@database_name,@object_name,@dump_type,@until_time,@bs_name95 96 return(@status)97 98 end99 100
exec sp_procxmode 'sp_querysmobj', 'AnyMode'
go
Grant Execute on sp_querysmobj to public
go