spTransactions_InsertProfileUpdate
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ClientID | int | IN | |
@UserID | int | IN | |
@BackOfficeID | int | IN | |
@xmlData | ntext | IN | |
@EmailJobRecipientID | int | IN |
Definition
Copy
CREATE PROCEDURE [dbo].[spTransactions_InsertProfileUpdate]
(
@ClientID int,
@UserID int,
@BackOfficeID int,
@xmlData ntext,
@EmailJobRecipientID int
)
AS
DECLARE @ret int
SET @ret=0
--profileupdate can only be done by a logged in user
-- if (@UserID is null) or (@UserID=0) begin
-- RAISERROR ('Unable to insert transaction - Profile Updates can only be done by a registered user',16,2)
-- return 0
-- end
if (@UserID is null) or (@UserID<1)
set @UserID = null
if (@BackOfficeID IS NULL) or (@BackOfficeID<1)
set @BackOfficeID = null
if @EmailJobRecipientID <= 0 set @EmailJobRecipientID = NULL
if (datalength(@xmlData) < 8)
begin
raiserror ('Unable to insert transaction - ProfileUpdateTransactions.XMLObjectData cannot be a zero-length string and must be well formed XML',16,1)
return 0
end
declare @lock_result int
begin tran
--use app lock to sync the block below
exec @lock_result=sp_getAppLock @Resource='Shelby.spTransactions_InsertProfileUpdate' ,@LockMode='Exclusive',@LockTimeOut=30000
if @lock_result < 0
begin
ROLLBACK TRAN
return 0
end
else
begin
begin
insert into dbo.ProfileUpdateTransactions
(clientsid,AddedByUserID,BackOfficeID,XMLObjectData,[EmailJobRecipientID])
values
(@clientid,@UserID,@BackOfficeID,@xmlData,@EmailJobRecipientID)
if @@error = 0
set @ret= SCOPE_IDENTITY()
else
set @ret= 0
end
--This will save or update the transaction into the BBNCTransactions Table
Declare @BBNCTransactionsPKID int
Set @BBNCTransactionsPKID = 0
Declare @TransactionType nvarchar(100)
Set @TransactionType = '{DCEAFCC7-0290-488e-A194-953DE66D6AAB}'
exec spTransactions_InsertTransaction @BBNCTransactionsPKID, @ret, @TransactionType, @xmlData, @UserID, @BackOfficeID
exec @lock_result=sp_releaseAppLock @resource='Shelby.spTransactions_InsertProfileUpdate'
commit tran
return @ret
end