spTransactions_AddUpdateCustomTransaction
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@TransactionTypeGuid | uniqueidentifier | IN | |
@TransactionId | int | IN | |
@ClientsID | int | IN | |
@UserID | int | IN | |
@xmlData | ntext | IN |
Definition
Copy
CREATE procedure dbo.spTransactions_AddUpdateCustomTransaction(
@TransactionTypeGuid uniqueidentifier,
@TransactionId integer,
@ClientsID integer,
@UserID integer,
@xmlData ntext)
as
begin
if (@UserID is null) or (@UserID < 1)
set @UserID = null
if (datalength(@xmlData) < 8)
begin
raiserror ('Unable to insert custom transaction - CustomTransactions.Data cannot be a zero-length string and must be well formed XML',16,1)
return 0
end
if @UserID=0 set @UserID=null
if (@TransactionId > 0)
update dbo.CustomTransactions
set
ClientsID = @ClientsID,
AddedByUserID = @UserID,
Data = @xmlData,
DateProcessed=null,
DateLastChanged=getutcdate()
where TransactionTypeGuid = @TransactionTypeGuid
and CustomTransactionID = @TransactionId
else
begin
insert into dbo.CustomTransactions(TransactionTypeGuid, ClientsID, AddedByUserID, Data)
values(@TransactionTypeGuid, @ClientsID, @UserID, @xmlData)
if @@error =0
set @TransactionId = @@identity
else
set @TransactionId = 0
end
return @TransactionId
end