USP_DATAFORMTEMPLATE_EDITLOAD_CONSTITUENTADDRESSUPDATEBATCHCOMMIT
The load procedure used by the edit dataform template "Constituent Address Update Batch Row Commit Edit Form"
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN | The input ID parameter used to load the fields defined on the form. |
@DATALOADED | bit | INOUT | Output parameter indicating whether or not data was actually loaded. |
@ADDRESSTYPECODEID | uniqueidentifier | INOUT | Address type |
@COUNTRYID | uniqueidentifier | INOUT | Country |
@ADDRESSBLOCK | nvarchar(150) | INOUT | Address |
@CITY | nvarchar(50) | INOUT | City |
@STATEID | uniqueidentifier | INOUT | State |
@POSTCODE | nvarchar(12) | INOUT | ZIP |
@ISPRIMARY | bit | INOUT | Set as primary address |
@DONOTMAIL | bit | INOUT | Do not send mail to this address |
@UPDATEMATCHINGSPOUSEADDRESSES | bit | INOUT | Update spouse address |
@VALIDATEONLY | bit | INOUT | Validate only |
@TSLONG | bigint | INOUT | Output parameter indicating the TSLONG value of the record being edited. This is used to manage multi-user concurrency issues when multiple users access the same record. |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDITLOAD_CONSTITUENTADDRESSUPDATEBATCHCOMMIT
(
@ID uniqueidentifier,
@DATALOADED bit = 0 output,
@ADDRESSTYPECODEID uniqueidentifier = null output,
@COUNTRYID uniqueidentifier = null output,
@ADDRESSBLOCK nvarchar(150) = null output,
@CITY nvarchar(50) = null output,
@STATEID uniqueidentifier = null output,
@POSTCODE nvarchar(12) = null output,
@ISPRIMARY bit = null output,
@DONOTMAIL bit = null output,
@UPDATEMATCHINGSPOUSEADDRESSES bit = null output,
@VALIDATEONLY bit = null output,
@TSLONG bigint = 0 output
) as
set nocount on;
set @DATALOADED = 0;
set @TSLONG = 0;
set @UPDATEMATCHINGSPOUSEADDRESSES = 0;
if exists(select object_id from sys.objects where type = 'U' and name = 'RELATIONSHIP') begin
declare @SPOUSEID uniqueidentifier;
select
@DATALOADED = 1,
@ADDRESSTYPECODEID = ADDRESS.[ADDRESSTYPECODEID],
@COUNTRYID = ADDRESS.[COUNTRYID],
@ADDRESSBLOCK = ADDRESS.[ADDRESSBLOCK],
@CITY = ADDRESS.[CITY],
@STATEID = ADDRESS.[STATEID],
@POSTCODE = ADDRESS.[POSTCODE],
@ISPRIMARY = ADDRESS.[ISPRIMARY],
@DONOTMAIL = ADDRESS.[DONOTMAIL],
@SPOUSEID = SPOUSE.[ID],
@TSLONG = ADDRESS.[TSLONG]
from
dbo.[ADDRESS]
left join dbo.[RELATIONSHIP] on RELATIONSHIP.[RELATIONSHIPCONSTITUENTID] = ADDRESS.[CONSTITUENTID] and RELATIONSHIP.[ISSPOUSE] = 1
left join dbo.[CONSTITUENT] as SPOUSE on SPOUSE.[ID] = RELATIONSHIP.[RECIPROCALCONSTITUENTID]
where
ADDRESS.[ID] = @ID;
if exists (
select ADDRESS.ID
from dbo.ADDRESS
where
ADDRESS.[CONSTITUENTID] = @SPOUSEID and
ADDRESS.[COUNTRYID] = @COUNTRYID and
ADDRESS.[ADDRESSBLOCK] = @ADDRESSBLOCK and
ADDRESS.[CITY] = @CITY and
(ADDRESS.[STATEID] = @STATEID or (ADDRESS.[STATEID] is null and @STATEID is null)) and
ADDRESS.[POSTCODE] = @POSTCODE
) begin
set @UPDATEMATCHINGSPOUSEADDRESSES = 1;
end
end
else
select
@DATALOADED = 1,
@ADDRESSTYPECODEID = ADDRESS.[ADDRESSTYPECODEID],
@COUNTRYID = ADDRESS.[COUNTRYID],
@ADDRESSBLOCK = ADDRESS.[ADDRESSBLOCK],
@CITY = ADDRESS.[CITY],
@STATEID = ADDRESS.[STATEID],
@POSTCODE = ADDRESS.[POSTCODE],
@ISPRIMARY = ADDRESS.[ISPRIMARY],
@DONOTMAIL = ADDRESS.[DONOTMAIL],
@TSLONG = ADDRESS.[TSLONG]
from
dbo.ADDRESS
where
ADDRESS.[ID] = @ID;
return 0;