Table of Contents


MDD Functions are fragments of MQL queries, defined alongside the data in the Makumba Data Definition. They can be used in

Defining MDD Functions#

MDD Functions are defined in the same file as the Makumba Data Definition they operate on. They can make use of the full MQL syntax, and directly use fields defined in the same data definition, as well as fields in relational types, i.e. in pointers and sets.

Remember the company data model described earlier in this section, specifically the company.Employee type:

company.Employee (company/Employee.mdd)

name = char[200]
surname = char[200]
gender = int{"Male" = 10, "Female" = 20}
birthdate = date
salary = real
department = ptr company.Department
projects = set
projects->project = ptr company.Project
projects->timePercentage = int ;percentage assigned

When we want to print the name of that employee in a JSP page, it is cumbersome to always do

Name: <mak:value expr=""/> <mak:value expr="employee.surnname"/> 

In this case, we can define an MDD function as a shortcut: company.Employee (company/Employee.mdd)

nameSurname() { concat(name, ' ', surname) }

and can thus use it in the JSP page:

Name: <mak:value expr="employee.nameSurname()"/>

To define this MDD function, we used the function concat, which has to be provided by the query language. MDD functions can return several data types, depending on the return type of the query language functions or operators used. You can find a list of currently supported functions in MQL.

Another example for an MDD function could be when you want to list employees that have their birthday today. You could do this by:

<mak:list from="company.Employee e" where="e.birthday=current_date()">
  <mak:value expr="e.nameSurname()"/> <br/>

or you could predefine this function:

company.Employee (company/Employee.mdd)

hasBirthday() { birthday = current_date() }

and then use it as:

<mak:list from="company.Employee e" where="e.hasBirthday()">
  <mak:value expr="e.nameSurname()"/> <br/>

When we want to display all employees that are ready for retirement, we could do this like follows:

company.Employee (company/Employee.mdd)

shallRetire() { year(birthday - current_date()) > 65 } 

and then use it as:

The following employees should retire:
<mak:list from="company.Employee e" where="e.shallRetire()">
  <mak:value expr="e.nameSurname()"/> <br/>

Category Usage

Add Comment
« This page was last updated on May 16 2010