$Database.Get
Overview
Executes the specified query and returns results as a DataTable instance.
Arguments
Query query
Query to execute.
Example
Basic Query
var myTable = $Database.Get({
Parameters : {
TargetSchema : 'HR',
TargetTable : 'Groups'
},
Where : {
Criteria : [
{
Name : 'Name',
Value : 'Administrators'
}
]
},
Order : [
{Name : 'Order', Type : 'Ascending'}
]
});
Example
In the example below we queried the Makers table. The result is ordered in descending order and there is only one row because we set the Start parameter to 0 and MaxLength to 1.
var myTable = $Database.Get({
Parameters : {
TargetSchema : 'HR',
TargetTable : 'Groups'
},
Columns : [
{Name : 'Order'}
],
Start : 0,
MaxLength : 1,
Where : {
Criteria : [
{Name : 'Name', Value : 'Administrators', Comparison : 'Different'}
]
},
Order : [
{Name : 'Name', Type : 'Descending'}
]
});
Example
For example if you need a more complex query, containing multiple AND/OR conditions like "(X OR Y OR Z) AND W", you can use Blocks option. Check the code sample below.
var myTable = $Database.Get({
Parameters : {
TargetSchema : 'HR',
TargetTable : 'UserLogons'
},
Where : {
Blocks : [{
Condition : 'And',
Criteria : [{
Name : 'User.EMailAddress',
Value : '...',
Condition : 'Or'
}, {
Name : 'User.EMailAddress',
Value : '...',
Condition : 'Or'
}, {
Name : 'User.EMailAddress',
Value : '...'
},]
}],
Criteria : [{
Name : 'User.Disabled',
Value : 'true',
Condition : 'And',
Comparison : 'Different'
}]
}
});
Example
In the query below days gained by an employee is selected with the sum function.
In the example below, offers by suppliers are grouped by the day they made with their count.
Example
Query with Expression - Advanced
See Also
Expressions
Copyright © 2010 - 2023 Emakin. All rights reserved.