QBGenericColumn
Overview
The QBGenericColumn
class represents a generic (untyped) column in a QBSelect
query.
For more information about constructing and executing queries and columns, refer to the QBSelect section of this documentation.
Extends
Properties Summarized
Methods Summarized
Properties Detailed
abs
Create abs(column) expression
Type QBColumn a QBColumn representing the absolute value of the column.
Sample
query.result.add(query.columns.custname.abs)
avg
Create an aggregate average expression.
Type QBColumn a QBColumn representing the average aggregate of the column.
Sample
var query = datasources.db.example_data.orders.createSelect();
query.groupBy.addPk() // have to group by on pk when using having-conditions in (foundset) pk queries
.root.having.add(query.joins.orders_to_order_details.columns.quantity.avg.eq(1))
foundset.loadRecords(query)
bit_length
Create bit_length(column) expression
Type QBColumn
Sample
query.result.add(query.columns.custname.bit_length)
cardinality
Create cardinality(column) expression
Type QBColumn
Sample
query.result.add(query.columns.arraycol.cardinality)
ceil
Create ceil(column) expression
Type QBColumn a QBIntegerColumn representing the ceil expression for the column.
Sample
query.result.add(query.columns.mycol.ceil)
day
Extract day from date
Type QBColumn a QBIntegerColumn representing the extraction of the day from a date.
Sample
query.result.add(query.columns.mydatecol.day)
floor
Create floor(column) expression
Type QBColumn a QBIntegerColumn representing the floor expression for the column.
Sample
query.result.add(query.columns.mycol.floor)
hour
Extract hour from date
Type QBColumn a QBIntegerColumn representing the extraction of the hour from a date.
Sample
query.result.add(query.columns.mydatecol.hour)
isNull
Compare column with null.
Type QBCondition a QBCondition representing the "is null" comparison.
Sample
query.where.add(query.columns.flag.isNull)
len
Create length(column) expression
Type QBColumn
Sample
query.result.add(query.columns.custname.len)
lower
Create lower(column) expression
Type QBColumn
Sample
query.result.add(query.columns.custname.lower)
max
Create an aggregate max expression.
Type QBColumn a QBColumn representing the sum aggregate function.
Sample
var query = datasources.db.example_data.orders.createSelect();
query.groupBy.addPk() // have to group by on pk when using having-conditions in (foundset) pk queries
.root.having.add(query.joins.orders_to_order_details.columns.quantity.count.max(10))
foundset.loadRecords(query)
min
Create an aggregate min expression.
Type QBColumn a QBColumn representing the minimum aggregate function.
Sample
var query = datasources.db.example_data.orders.createSelect();
query.groupBy.addPk() // have to group by on pk when using having-conditions in (foundset) pk queries
.root.having.add(query.joins.orders_to_order_details.columns.quantity.count.min(10))
foundset.loadRecords(query)
minute
Extract minute from date
Type QBColumn a QBIntegerColumn representing the extraction of the minute from a date.
Sample
query.result.add(query.columns.mydatecol.minute)
month
Extract month from date
Type QBColumn a QBIntegerColumn representing the extraction of the month from a date.
Sample
query.result.add(query.columns.mydatecol.month)
not
Create a negated condition.
Type QBGenericColumnComparable a QBColumn representing the negated condition.
Sample
query.where.add(query.columns.flag.not.eq(1))
round
Create round(column) expression
Type QBColumn a QBIntegerColumn representing the round expression for the column.
Sample
query.result.add(query.columns.mycol.round)
second
Extract second from date
Type QBColumn a QBIntegerColumn representing the extraction of the second from a date.
Sample
query.result.add(query.columns.mydatecol.second)
sqrt
Create sqrt(column) expression
Type QBColumn a QBNumberColumn representing the square root of the column.
Sample
query.result.add(query.columns.custname.sqrt)
sum
Create an aggregate sum expression.
Type QBColumn a QBColumn representing the sum aggregate of the column.
Sample
var query = datasources.db.example_data.orders.createSelect();
query.groupBy.addPk() // have to group by on pk when using having-conditions in (foundset) pk queries
.root.having.add(query.joins.orders_to_order_details.columns.quantity.sum.gt(100))
foundset.loadRecords(query)
trim
Create trim(column) expression
Type QBColumn
Sample
query.result.add(query.columns.custname.trim)
upper
Create upper(column) expression
Type QBColumn
Sample
query.result.add(query.columns.custname.upper)
year
Extract year from date
Type QBColumn a QBIntegerColumn representing the extraction of the year from a date.
Sample
query.result.add(query.columns.mydatecol.year)
Methods Detailed
between(value1, value2)
Compare column to a range of 2 values or other columns.
Parameters
Returns: QBCondition a QBCondition representing the "between" comparison for the two values.
Sample
query.where.add(query.columns.flag.between(0, 5))
coalesce(value)
Create coalesce(arg) expression
Parameters
Object value when column is null
Returns: QBColumn a QBColumn representing the coalesce expression.
Sample
query.result.add(query.columns.mycol.coalesce('defval'))
divide(value)
Divide by value
Parameters
Object value nr to divide by
Returns: QBColumn a QBNumberColumn representing the column divided by the value.
Sample
query.result.add(query.columns.mycol.divide(2))
eq(value)
Compare column with a value or another column. Operator: equals
Parameters
Object value ;
Returns: QBCondition a QBCondition representing the "equals" comparison.
Sample
query.where.add(query.columns.flag.eq(1))
ge(value)
Compare column with a value or another column. Operator: greaterThanOrEqual
Parameters
Object value ;
Returns: QBCondition a QBCondition representing the "greater than or equal to" comparison.
Sample
query.where.add(query.columns.flag.ge(2))
gt(value)
Compare column with a value or another column. Operator: greaterThan
Parameters
Object value ;
Returns: QBCondition a QBCondition representing the "greater than" comparison.
Sample
query.where.add(query.columns.flag.gt(0))
isin(query)
Compare column with subquery result.
Parameters
QBPart query subquery
Returns: QBCondition a QBCondition representing the "in" comparison with a subquery.
Sample
query.where.add(query.columns.flag.isin(query2))
isin(values)
Compare column with values.
Parameters
Array values array of values
Returns: QBCondition a QBCondition representing the "in" comparison with a list of values.
Sample
query.where.add(query.columns.flag.isin([1, 5, 99]))
isin(customQuery, args)
Compare column with custom query result.
Parameters
Returns: QBCondition a QBCondition representing the "in" comparison with a custom query and arguments.
Sample
query.where.add(query.columns.ccy.isin("select ccycode from currencies c where c.category = " + query.getTableAlias() + ".currency_category and c.flag = ?", ['T']))
le(value)
Compare column with a value or another column. Operator: lessThanOrEqual
Parameters
Object value ;
Returns: QBCondition a QBCondition representing the "less than or equal to" comparison.
Sample
query.where.add(query.columns.flag.le(2))
like(pattern)
Compare column with a value or another column. Operator: like
Parameters
Object pattern the string value of the pattern
Returns: QBCondition the QBCondition that can be added to a where clause
Sample
query.where.add(query.columns.companyname.like('Serv%'))
// case-insensitive compares can be done using the upper (or lower) functions,
// this can be useful when using for example German letters like ß,
query.where.add(query.columns.companyname.upper.like(query.functions.upper('groß%')))
like(pattern, escape)
Compare column with a value or another column. Operator: like, with escape character
Parameters
Returns: QBCondition the QBCondition that can be added to a where clause
Sample
query.where.add(query.columns.companyname.like('X_%', '_')
locate(arg)
Create locate(arg) expression
Parameters
Object arg string to locate
Returns: QBColumn the QBIntegerColumn that can be added to the result.
Sample
query.result.add(query.columns.mycol.locate('sample'))
locate(arg, start)
Create locate(arg, start) expression
Parameters
Returns: QBColumn the QBIntegerColumn that can be added to the result.
Sample
query.result.add(query.columns.mycol.locate('sample', 5))
lt(value)
Compare column with a value or another column. Operator: lessThan
Parameters
Object value ;
Returns: QBCondition a QBCondition representing the "less than" comparison.
Sample
query.where.add(query.columns.flag.lt(99))
minus(value)
Subtract value
Parameters
Object value nr to subtract
Returns: QBColumn a QBNumberColumn representing the column substracted with the value.
Sample
query.result.add(query.columns.mycol.minus(2))
mod(arg)
Create mod(arg) expression
Parameters
Object arg mod arg
Returns: QBColumn a QBColumn representing the modulo of the column.
Sample
query.result.add(query.columns.mycol.mod(2))
multiply(value)
Multiply with value
Parameters
Object value nr to multiply with
Returns: QBColumn a QBNumberColumn representing the column multiplied with the value.
Sample
query.result.add(query.columns.mycol.multiply(2))
nullif(arg)
Create nullif(arg) expression
Parameters
Object arg object to compare
Returns: QBColumn a QBColumn representing the nullif expression.
Sample
query.result.add(query.columns.mycol.nullif('none'))
plus(value)
Add up value
Parameters
Object value nr to add
Returns: QBColumn a QBNumberColumn representing the column added with the value.
Sample
query.result.add(query.columns.mycol.plus(2))
substring(pos)
Create substring(pos) expression
Parameters
Number pos ;
Returns: QBColumn the QBTextColumn that can be added to the result.
Sample
query.result.add(query.columns.mycol.substring(3))
substring(pos, len)
Create substring(pos, len) expression
Parameters
Returns: QBColumn the QBTextColumn that can be added to the result.
Sample
query.result.add(query.columns.mycol.substring(3, 2))
Last updated
Was this helpful?