UFN_REVENUEBATCH_PARSEAPPLICATIONINFO
Parses the revenue batch application info field. Assumes it is in the form of 'applicaitonid as guid':'applicationtypecode as tinyint':'amount as money'.
Return
Return Type |
---|
table |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@APPLICATIONINFO | nvarchar(60) | IN |
Definition
Copy
create function dbo.UFN_REVENUEBATCH_PARSEAPPLICATIONINFO(
@APPLICATIONINFO nvarchar(60)
)
returns @RESULT table
(
SINGLEAPPLICATIONID uniqueidentifier,
APPLICATIONTYPECODE int,
APPLICATIONAMOUNT money
)
as
begin
--Assume @APPLICATIONINFO is in the form '<applicationid guid>:<applicationtypecode tinyint>:<amount money>'
--Since we should not assume appicationcode will be < 10, parse based on separator locations and not assumed lengths
declare @SEPARATOR1INDEX tinyint;
declare @SEPARATOR2INDEX tinyint;
set @SEPARATOR1INDEX = charindex(':', @APPLICATIONINFO)
set @SEPARATOR2INDEX = charindex(':', @APPLICATIONINFO, @SEPARATOR1INDEX + 1)
insert into @RESULT
select
cast(substring(@APPLICATIONINFO, 1, @SEPARATOR1INDEX - 1) as uniqueidentifier),
cast(substring(@APPLICATIONINFO, @SEPARATOR1INDEX + 1, (@SEPARATOR2INDEX - @SEPARATOR1INDEX) - 1) as int),
cast(substring(@APPLICATIONINFO, @SEPARATOR2INDEX + 1, len(@APPLICATIONINFO)-@SEPARATOR2INDEX) as money)
return;
end