Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE PROCEDURE [dbo].[cust_CCIW_get_save_seasonal_address]
- @OrganizationID INT,
- @Guid UNIQUEIDENTIFIER,
- @FromMonthDay VARCHAR(4),
- @ToMonthDay VARCHAR(4),
- @AddressLUID INT = -1
- AS
- BEGIN
- IF @ToMonthDay != ''
- AND @FromMonthDay != ''
- AND LEN(@FromMonthDay) = 4
- AND LEN(@ToMonthDay) = 4
- BEGIN
- UPDATE core_person_address
- SET from_month_day = @FromMonthDay,
- to_month_day = @ToMonthDay
- FROM core_person P
- JOIN core_family_member M1 ON M1.person_id = P.person_id
- JOIN core_family_member M2 ON M1.family_id = M2.family_id
- JOIN core_person_address A2 ON A2.person_id = M2.person_id
- WHERE P.guid = @Guid
- AND A2.address_type_luid = @AddressLUID
- END
- IF (@ToMonthDay = '' AND @FromMonthDay != '')
- OR (@ToMonthDay != '' AND @FromMonthDay = '')
- BEGIN
- SELECT 'Please input both To and From dates' AS 'Error Message'
- END
- ELSE IF (@ToMonthDay = '' AND @FromMonthDay = '')
- BEGIN
- SELECT CPA.* FROM core_person P
- JOIN core_person_address CPA ON P.person_id = CPA.person_id
- WHERE P.guid = @Guid
- AND CPA.address_type_luid = @AddressLUID
- END
- ELSE IF (LEN(@FromMonthDay) != 4 OR LEN(@ToMonthDay) != 4)
- BEGIN
- SELECT 'Unsupported date format' AS 'Error Message'
- END
- ELSE
- BEGIN
- SELECT CPA.* FROM core_person P
- JOIN core_person_address CPA ON P.person_id = CPA.person_id
- WHERE P.guid = @Guid
- AND CPA.address_type_luid = @AddressLUID
- END
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement