COLLECTION and KEY

This math element can be used to create a collection, set the value of a math variable from an existing math variable or activity field, or execute a SQL statement that will return two result columns as a key-value pair. In the latter case, the first column is considered the key with the second column a value. A subsequent statement of type COLLECTIONVALUE is used to access the key to retrieve its associated value  (see the last XML example).

COLLECTION and KEY: Elements and Attributes
TYPE=COLLECTION KEY=GUID
Element Attributes Parent Element Description Element/Attribute Value Element Value

OPERATION="CREATE"   

         

<MathVariable>

 

 

 

         

VARIABLENAME

   

String: The name of the math variable.

 

TYPE

   

COLLECTION

 

OPERATION    

CREATE

Creates a COLLECTION math variable.

 

DATATYPE

   

MAP

 

ORDERED    

Yes: The order of the collection will be persisted until the final instance of the math variable.

No: The order of the collection will not be persisted. This is the default behavior if this attribute is omitted from configuration.

Note: This Ordered Attribute for TYPE = COLLECTION is an additional optional attribute and is only applicable for screenmath. if it is used in ActivityMath, it would get omitted or ignored.

 

OPERATION="SETVALUE"   

         

<MathVariable>

      String: Refers to the name of a COLLECTION math variable created with OPERATION="CREATE".

 

VARIABLENAME

   

String

The name of the math variable whose value is set by this configuration.

 

TYPE

   

COLLECTION

 

OPERATION

   

SETVALUE

Assigns a value to an existing or new math variable once the collection is created. Use a previously defined Math Variable or Activity Field to replace the value.

 

DATATYPE

   

BIGTEXT
DATE
TEXT
INTEGER
DECIMAL

 

ROUND

   

Integer

If DATATYPE="DECIMAL"

 

KEY

   

The KEY indicates the type of value the configuror is using to map or insert into a new math variable name within the collection. For example a SegmentGUID for a SegmentLoop to update the face amount or active code, a unique naming convention, or fund code.

 

DEFAULT

   

String

 

LOG

   

Yes:  the result is stored in AsActivityMath table to be used by other activities.

No: the result is not stored. This is the default behavior.  

 

ORDERED    

Yes: The order of the collection will be persisted until the final instance of the math variable. This behavior is akin to the LOG attribute being set to "Yes".

No: The order of the collection will not be persisted. This is the default behavior if this attribute is omitted from configuration.

Note: If the ORDERED attribute is used on a COLLECTION math variable with OPERATION set to "SETVALUE", ORDERED must be used on the first instance of the collection that inserts a value.

Note: This Ordered Attribute for TYPE = COLLECTION is an additional optional attribute and is only applicable for screenmath. if it is used in ActivityMath, it would get omitted or ignored.

 

OPERATION attribute omitted   

         

<MathVariable>

 

 

 

      Option 1: One of the following:   

<SqlServer>[SqlStatement]</SqlServer>

<Oracle>[SqlStatement]</Oracle>

<DB2>[SqlStatement]</DB2>

Option 2:   

[SqlStatement]

 

VARIABLENAME

   

String

 

TYPE

   

COLLECTION

 

DATATYPE

   

MAP

 

ORDERED

   

Yes: The order of the collection will be persisted until the final instance of the math variable.

No: The order of the collection will not be persisted. This is the default behavior if this attribute is omitted from configuration.

Note: This Ordered Attribute for TYPE = COLLECTION is an additional optional attribute and is only applicable for screenmath. if it is used in ActivityMath, it would get omitted or ignored.

 

CLEARVALUE

   

Optional attribute: 

Yes: The value of the math variable will be deleted after the execution of all the Attached Rules at the end of activity processing and will not be visible on the Math tab in the Activity details screen.

No: The value of the math variable will be retained after activity processing and will be displayed in the Math tab in the Activity details screen.

Default Value: No

XML Schema

OPERATION="CREATE"

<MathVariable VARIABLENAME="[String]" TYPE="COLLECTION" 
OPERATION="CREATE" 
DATATYPE="MAP">
</MathVariable>

OPERATION="SETVALUE"

<MathVariable VARIABLENAME="[String]" TYPE="COLLECTION" 
OPERATION="SETVALUE" KEY="[String]" DATATYPE="DATE|TEXT|INTEGER|DECIMAL" 
ROUND="[Integer]" DEFAULT="[String]" LOG="Yes">[String]
</MathVariable>

OPERATION attribute omitted

<MathVariable VARIABLENAME="[String]" TYPE="COLLECTION" DATATYPE="MAP">
<!-- option 1 -->
<SqlServer>[SqlStatement]</SqlServer>|<Oracle>[SqlStatement]</Oracle>|<DB2>[SqlStatement]</DB2>
<!-- option 2 -->
[SqlStatement]
</MathVariable>

XML Examples

OPERATION="CREATE"

<MathVariable VARIABLENAME="SegmentAnnPremiumAmt" TYPE="COLLECTION" 
OPERATION="CREATE" DATATYPE="MAP"/>

OPERATION="SETVALUE"

<MathVariable VARIABLENAME="SegmentAnnPremiumAmt" TYPE="COLLECTION" 
OPERATION="SETVALUE" KEY="CurrentSegmentGUID" DATATYPE="CURRENCY" ORDERED="YES">CurrentYearsAnnualPremiumUSD
</MathVariable>

OPERATION attribute omitted

<MathVariable VARIABLENAME="SegmentCollection" TYPE="COLLECTION" DATATYPE="MAP">
SELECT Field.FieldName, 
CASE 
WHEN Field.FieldTypeCode = '02' THEN Field.TextValue 
WHEN Field.FieldTypeCode = '03' THEN CAST(Field.IntValue AS CHAR(10)) 
WHEN Field.FieldTypeCode = '04' THEN CAST(Field.FloatValue AS CHAR(32)) 
END 
FROM AsSegment 
JOIN AsSegmentName ON AsSegmentName.SegmentNameGUID = AsSegment.SegmentNameGUID 
AND AsSegmentName.TypeCode = '04' 
JOIN AsSegmentField Field ON Field.SegmentGUID = AsSegment.SegmentGUID 
AND Field.FieldName IN ('SegmentIssueGender', 
			'SegmentUWClass', 
			'SegmentTobaccoPremBasis', 
			'SegmentAmount', 
			'SegmentIssueAge') 
WHERE AsSegment.PolicyGUID = '[Policy:PolicyGUID]'
</MathVariable>
 

COLLECTIONVALUE Example

<MathVariable VARIABLENAME="BaseFace" TYPE="COLLECTIONVALUE" 
KEY="SegmentAmount" DATATYPE="DECIMAL" DEFAULT="-999999999">SegmentCollection
</MathVariable>