USP_SURVEYRESPONSE_GETRESPONSES_ADDFROMXML
Used to add a set of records defined by UFN_SURVEYRESPONSE_GETRESPONSES from the given xml string.
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@SURVEYID | uniqueidentifier | IN | |
@XML | xml | IN | |
@CHANGEAGENTID | uniqueidentifier | IN | |
@CHANGEDATE | datetime | IN |
Definition
Copy
/*
Generated by Blackbaud AppFx Platform
Date: 12/17/2008 2:34:25 AM
Assembly Version: Blackbaud.AppFx.Platform.SqlClr, Version=1.7.1271.0, Culture=neutral, PublicKeyToken=null
Copyright Blackbaud
*/
CREATE PROCEDURE dbo.USP_SURVEYRESPONSE_GETRESPONSES_ADDFROMXML
(
@SURVEYID uniqueidentifier,
@XML xml,
@CHANGEAGENTID uniqueidentifier = null,
@CHANGEDATE datetime = null
)
as
set nocount on;
if @CHANGEAGENTID is null
exec USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
if @CHANGEDATE is null
set @CHANGEDATE = getdate()
-- build a temporary table containing the values from the XML
declare @TempTbl table (
[BBNCQUESTIONID] int,
[BBNCRESPONSEID] int,
[ID] uniqueidentifier,
[QUESTION] nvarchar(max),
[RESPONSE] nvarchar(max))
insert into @TempTbl select
[BBNCQUESTIONID],
[BBNCRESPONSEID],
[ID],
[QUESTION],
[RESPONSE]
from dbo.UFN_SURVEYRESPONSE_GETRESPONSES_FROMITEMLISTXML(@XML)
update @TempTbl set ID = newid() where (ID is null) or (ID = '00000000-0000-0000-0000-000000000000');
if @@Error <> 0
return 1;
-- insert new items
insert into [SURVEYRESPONSE]
([SURVEYID],
[BBNCQUESTIONID],
[BBNCRESPONSEID],
[ID],
[QUESTION],
[RESPONSE],
ADDEDBYID,
CHANGEDBYID,
DATEADDED,
DATECHANGED)
select @SURVEYID,
[BBNCQUESTIONID],
[BBNCRESPONSEID],
[ID],
[QUESTION],
[RESPONSE],
@CHANGEAGENTID,
@CHANGEAGENTID,
@CHANGEDATE,
@CHANGEDATE
from @TempTbl as [temp]
if @@Error <> 0
return 2;
return 0;