USP_PDACCOUNTSYSTEM_DELETE
Executes the "Delete Accounting System" 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_PDACCOUNTSYSTEM_DELETE
(
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier
)
as begin
--check deletion rules, if any
if dbo.UFN_PDACCOUNTSYSTEM_CANDELETE(@ID) = 0
raiserror('ERR_PDACCOUNTSYSTEM_HASACCOUNTS',13,1)
-- Delete the Structure. (Bug 98678)
declare @e int;
declare @contextCache varbinary(128);
/* cache current context information */
set @contextCache = CONTEXT_INFO();
/* set CONTEXT_INFO to @CHANGEAGENTID */
if not @CHANGEAGENTID is null
set CONTEXT_INFO @CHANGEAGENTID
/* Note we are deleting by Account System ID */
delete from dbo.PDACCOUNTSTRUCTURE where PDAccountSystemID=@ID;
/* reset CONTEXT_INFO to previous value */
if not @contextCache is null
set CONTEXT_INFO @contextCache
select @e=@@error;
if @e<>0 return -456; --always return non-zero sp result if an error occurs
-- use the system generated delete routine to allow proper recording of the deleting agent
exec USP_PDACCOUNTSYSTEM_DELETEBYID_WITHCHANGEAGENTID @ID, @CHANGEAGENTID
return 0;
end