DataMgr 2.5 Documentation: Math


The "math" relation allows you to perform basic mathematical operations between two fields from within DataMgr. The operators allows are: +-*/, for addition, subtraction, multiplication, and division respectively.


Among the uses for this is the ability to calculate an order total in a cart. Each line item could have a total cost that is a multiplication of the quantity by price. The order itself could then add these values for the pre-tax total and take that number and multiply it by the tax rate (pulled from another relation field). All of this could now be done from within DataMgr without writing any SQL.

Example (XML):

<field ColumnName="MyField">
	<relation type="math" field1="OrderTotal" field2="TaxRate" operator="*" />

Example (setColumn):

cfset sRelation = StructNew()>
<cfset sRelation.type = "math">
<cfset sRelation.field1= "OrderTotal">
<cfset sRelation.field2= "TaxRate">
<cfset sRelation.operator= "*">
<cfset Application.DataMgr.setColumn(tablename="MyTable",ColumnName="MyField",Relation=sRelation)>