Utility methods in the query builder APIs

The following methods on the DBFunction class provide useful functions in query builder code.

Method

Description

Example

Constant

Coerces a Gosu literal to an SQL literal in the generated SQL query that PolicyCenter submits to the database

query.compare(Address#City, Equals,
        DBFunction.Constant("Los Angeles"))

DateDiff

Returns the Interval between two date and time columns

query.compare(DBFunction.DateDIff(DAYS, 
        getColumnRef("AssignmentDate"), 
        getColumnRef("EndDate")),
        LessThan, 15)

DatePart

Returns parts of a date and time column value, such as day or month

query.compare(DBFunction.DatePart(DAY_OF_MONTH,
        query.getColumnRef("AssignmentDate")), 
        NotEquals, 15) 

DateFromTimestamp

Returns the date portion of a timestamp

query.compare(DBFunction.DateFromTimestamp(
        query.getColumnRef("CreateTime")), 
        Equals, gw.api.util.DateUtil.currentDate()) 
Distance Returns the distance between the location of an entity instance and a reference location
QuerySelectColumns.dbFunctionWithAliasDistance", 
        DBFunction.Distance(addressQuery, 
         "Address.SpatialPoint")) 

Expr

Returns a function defined by a list of column references and character sequences

See also