USP_SMARTQUERYUSERDEFINED_DELETE
Executes the "User-defined Smart Query: Delete" record operation.
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN | Input parameter indicating the ID of the record being deleted. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the delete. |
Definition
Copy
create procedure dbo.USP_SMARTQUERYUSERDEFINED_DELETE
(
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier
)
as
set nocount on;
begin try
declare @CONTEXTCACHE varbinary(128);
set @CONTEXTCACHE = CONTEXT_INFO();
if @CHANGEAGENTID is not null
set CONTEXT_INFO @CHANGEAGENTID;
if exists (select 1 from dbo.SMARTQUERYINSTANCE where SMARTQUERYCATALOGID = @ID)
begin
raiserror('BBERR_SMARTQUERY_SMARTQUERYHASINSTANCES', 13, 1);
return 1;
end;
with xmlnamespaces('bb_appfx_smartquery' as ns, 'bb_appfx_commontypes' as c)
delete
from dbo.SMARTQUERYCATALOG
where
ID = @ID
and SMARTQUERYCATALOG.SMARTQUERYSPEC.value('ns:SmartQuerySpec[1]/c:MetaTags[1]/AdHocQuerySaveSmartQueryRequest[1]', 'nvarchar(max)') is not null
if @CONTEXTCACHE is not null
set CONTEXT_INFO @CONTEXTCACHE;
end try
begin catch
exec dbo.USP_RAISE_ERROR;
return 1;
end catch;
return 0;