UFN_PDCATEGORYDEFINITION_CHECKEXISTINGACCOUNTS
Validates that changes to FROMCODE and TOCODE do not make existing account codes invalid.
Return
Return Type |
---|
bit |
Definition
Copy
create function dbo.UFN_PDCATEGORYDEFINITION_CHECKEXISTINGACCOUNTS()
returns bit
with execute as caller
as begin
declare @retval bit = 1
declare @SegID uniqueidentifier
declare @Length int
select @SegID = ID, @Length = LENGTH from dbo.PDACCOUNTSTRUCTURE where SEGMENTTYPE = 1
if (select min(len(nullif(FROMCODE,''))) from PDCATEGORYDEFINITION) = @Length and (select max(len(nullif(FROMCODE,''))) from PDCATEGORYDEFINITION) = @Length and (select min(len(nullif(TOCODE,''))) from PDCATEGORYDEFINITION) = @Length and (select max(len(nullif(TOCODE,''))) from PDCATEGORYDEFINITION) = @Length
begin
if exists(select * from dbo.PDACCOUNTSEGMENTVALUE t1 where PDACCOUNTSTRUCTUREID = @SegID and not exists(select * from dbo.PDCATEGORYDEFINITION where convert(int,t1.SHORTDESCRIPTION) between convert(int,FROMCODE) and convert(int,TOCODE)))
set @retval = 0
end
return @retval
end