Child pages
  • QBSelect

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Div
styledisplay:none

DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING.
THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR.

Div
iddescription



HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Property Summary
Table Row (tr)
Table Cell (td)
QBLogicalCondition
Table Cell (td)
and
Create an AND-condition to add conditions to.
Table Row (tr)
Table Cell (td)
QBColumns
Table Cell (td)
columns
Get columns from query
Table Row (tr)
Table Cell (td)
QBFunctions
Table Cell (td)
functions
Get the functions clause from a query, used for functions that are not tied to a column.
Table Row (tr)
Table Cell (td)
QBGroupBy
Table Cell (td)
groupBy
Get the group by clause from a query
Table Row (tr)
Table Cell (td)
QBLogicalCondition
Table Cell (td)
having
Get the having-part of the query, used to add conditions.
Table Row (tr)
Table Cell (td)
QBJoins
Table Cell (td)
joins
Get the joins clause of this table based clause.
Table Row (tr)
Table Cell (td)
QBLogicalCondition
Table Cell (td)
or
Create an OR-condition to add conditions to.
Table Row (tr)
Table Cell (td)
QBParameters
Table Cell (td)
params
Get the named parameters from a query.
Table Row (tr)
Table Cell (td)
QBTableClause
Table Cell (td)
parent
Get query builder parent table clause, this may be a query or a join clause.
Table Row (tr)
Table Cell (td)
QBResult
Table Cell (td)
result
Get the result part of the query, used to add result columns or values.
Table Row (tr)
Table Cell (td)
QBSelect
Table Cell (td)
root
Get query builder parent.
Table Row (tr)
Table Cell (td)
QBSorts
Table Cell (td)
sort
Get the sorting part of the query.
Table Row (tr)
Table Cell (td)
QBWhereCondition
Table Cell (td)
where
Get the where-part of the query, used to add conditions.



HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Summary
Table Row (tr)
Table Cell (td)
QBSelect
Table Cell (td)
clearHaving()
Clear the having-part of the query.
Table Row (tr)
Table Cell (td)
QBCondition
Table Cell (td)
exists()
Get an exists-condition from a subquery
Table Row (tr)
Table Cell (td)
QBColumn
Table Cell (td)
getColumn(name)
Get a column from the table.
Table Row (tr)
Table Cell (td)
QBColumn
Table Cell (td)
getColumn(columnTableAlias, name)
Get a column from the table with given alias.
Table Row (tr)
Table Cell (td)
QBParameter
Table Cell (td)
getParameter()
Get or create a parameter for the query, this used to parameterize queries.
Table Row (tr)
Table Cell (td)
QBCondition
Table Cell (td)
not(cond)
Create an negated condition.
Table Row (tr)
Table Cell (td)
QBCondition
Table Cell (td)
not(cond)
Create an negated condition.



HTML Table
idproperty
classservoy sDetail
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Property Details
Table Body (tbody)
idand
Table Row (tr)
idname
Table Cell (td)

and

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Create an AND-condition to add conditions to.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBLogicalCondition
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
query.where.add(
	  query.or
	    .add(
	      query.and
		    .add(query.columns.flag.eq(1))
	    .add(query.columns.order_date.isNull)
		 )
	    .add(
	      query.and
	        .add(query.columns.flag.eq(2))
	        .add(query.column.order_date.gt(new Date()))
	     )
	);
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idcolumns
Table Row (tr)
idname
Table Cell (td)

columns

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get columns from query
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBColumns
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
foundset.getQuery().columns
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idfunctions
Table Row (tr)
idname
Table Cell (td)

functions

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get the functions clause from a query, used for functions that are not tied to a column.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBFunctions
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
/** @type {QBSelect<db:/example_data/orders>} */
var query = databaseManager.createSelect('db:/example_data/orders') //$NON-NLS-1$
query.where.add(query.columns.shipname.upper.eq(query.functions.upper('servoy'))) //$NON-NLS-1$
foundset.loadRecords(query)
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgroupBy
Table Row (tr)
idname
Table Cell (td)

groupBy

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get the group by clause from a query
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBGroupBy
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
/** @type {QBSelect<db:/example_data/orders>} */
var query = databaseManager.createSelect('db:/example_data/orders')
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.eq(0))
foundset.loadRecords(query)
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idhaving
Table Row (tr)
idname
Table Cell (td)

having

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get the having-part of the query, used to add conditions.
The conditions added here are AND-ed.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBLogicalCondition
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
/** @type {QBSelect<db:/example_data/orders>} */
var query = databaseManager.createSelect('db:/example_data/orders')
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.eq(0))
foundset.loadRecords(query)
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idjoins
Table Row (tr)
idname
Table Cell (td)

joins

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get the joins clause of this table based clause.
Joins added to this clause will be based on this table clauses table.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBJoins
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
foundset.getQuery().joins
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idor
Table Row (tr)
idname
Table Cell (td)

or

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Create an OR-condition to add conditions to.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBLogicalCondition
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
query.where.add(
	  query.or
	    .add(
	      query.and
		    .add(query.columns.flag.eq(1))
	    .add(query.columns.order_date.isNull)
		 )
	    .add(
	      query.and
	        .add(query.columns.flag.eq(2))
	        .add(query.column.order_date.gt(new Date()))
	     )
	);
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idparams
Table Row (tr)
idname
Table Cell (td)

params

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get the named parameters from a query.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBParameters
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
/** @type {QBSelect<db:/example_data/orders>} */
	var query = databaseManager.createSelect('db:/example_data/orders')
	query.where.add(query.columns.contact_id.eq(query.getParameter('mycontactid')))

	// load orders where contact_id = 100
	query.params['mycontactid'] = 100
	foundset.loadRecords(query)

	// load orders where contact_id = 200
	query.params['mycontactid'] = 200
	foundset.loadRecords(query)
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idparent
Table Row (tr)
idname
Table Cell (td)

parent

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get query builder parent table clause, this may be a query or a join clause.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBTableClause
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
/** @type {QBSelect<db:/example_data/person>} */
	var query = databaseManager.createSelect('db:/example_data/person')
	query.where.add(query.joins.person_to_parent.joins.person_to_parent.columns.name.eq('john'))
	foundset.loadRecords(query)
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idresult
Table Row (tr)
idname
Table Cell (td)

result

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get the result part of the query, used to add result columns or values.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBResult
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
query.result.add(query.columns.company_id).add(query.columns.customerid)
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idroot
Table Row (tr)
idname
Table Cell (td)

root

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get query builder parent.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBSelect
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
/** @type {QBSelect<db:/example_data/order_details>} */
	var subquery = databaseManager.createSelect('db:/example_data/order_details')

 /** @type {QBSelect<db:/example_data/orders>} */
	var query = databaseManager.createSelect('db:/example_data/orders')
	query.where.add(query
		.or
			.add(query.columns.order_id.not.isin([1, 2, 3]))

			.add(query.exists(
					subquery.where.add(subquery.columns.orderid.eq(query.columns.order_id)).root
			))
		)

	foundset.loadRecords(query)
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idsort
Table Row (tr)
idname
Table Cell (td)

sort

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get the sorting part of the query.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBSorts
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
/** @type {QBSelect<db:/example_data/orders>} */
var query = databaseManager.createSelect('db:/example_data/orders')
query.sort
.add(query.joins.orders_to_order_details.columns.quantity.desc)
.add(query.columns.companyid)
foundset.loadRecords(query)
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idwhere
Table Row (tr)
idname
Table Cell (td)

where

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get the where-part of the query, used to add conditions.
The conditions added here are AND-ed.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBWhereCondition
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var query = foundset.getQuery()
query.where.add(query.columns.flag.eq(1))
Table Row (tr)
classlastDetailRow
Table Cell (td)
 



HTML Table
idfunction
classservoy sDetail
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Details
Table Body (tbody)
idclearHaving
Table Row (tr)
idname
Table Cell (td)

clearHaving

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
QBSelect
Span
stylefont-weight: bold;
clearHaving
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Clear the having-part of the query.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBSelect
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var q = foundset.getQuery()
q.where.add(q.columns.x.eq(100))
query.groupBy.clear.root.clearHaving()
foundset.loadRecords(q);
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idexists
Table Row (tr)
idname
Table Cell (td)

exists

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
QBCondition
Span
stylefont-weight: bold;
exists
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get an exists-condition from a subquery
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBCondition
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
foundset.query.where.add(query.exists(query2))
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetColumn-String
Table Row (tr)
idname
Table Cell (td)

getColumn

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
QBColumn
Span
stylefont-weight: bold;
getColumn
Span
(name)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get a column from the table.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} name - the name of column to get
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBColumn
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
foundset.getQuery().getColumn('orderid')
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetColumn-String_String
Table Row (tr)
idname
Table Cell (td)

getColumn

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
QBColumn
Span
stylefont-weight: bold;
getColumn
Span
(columnTableAlias, name)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get a column from the table with given alias.
The alias may be of the main table or any level deep joined table.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} columnTableAlias - the alias for the table
{String} name - the name of column to get
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBColumn
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
foundset.getQuery().getColumn('orderid', 'opk')
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetParameter
Table Row (tr)
idname
Table Cell (td)

getParameter

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
QBParameter
Span
stylefont-weight: bold;
getParameter
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get or create a parameter for the query, this used to parameterize queries.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBParameter
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
/** @type {QBSelect<db:/example_data/orders>} */
	var query = databaseManager.createSelect('db:/example_data/orders')
	query.where.add(query.columns.contact_id.eq(query.getParameter('mycontactid')))

	// load orders where contact_id = 100
	query.params['mycontactid'] = 100
	foundset.loadRecords(query)

	// load orders where contact_id = 200
	query.params['mycontactid'] = 200
	foundset.loadRecords(query)
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idnot-QBCondition
Table Row (tr)
idname
Table Cell (td)

not

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
QBCondition
Span
stylefont-weight: bold;
not
Span
(cond)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Create an negated condition.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{QBCondition} cond - the condition to negate
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBCondition
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
foundset.query.where.add(query.not(query.columns.flag.eq(1)))
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idnot-QBLogicalCondition
Table Row (tr)
idname
Table Cell (td)

not

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
QBCondition
Span
stylefont-weight: bold;
not
Span
(cond)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Create an negated condition.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{QBLogicalCondition} cond - the logical condition to negate
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
QBCondition
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
foundset.query.where.add(query.not(query.columns.flag.eq(1)))
Table Row (tr)
classlastDetailRow
Table Cell (td)