Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

...

DataTable my$Database $Database.Get(query: Query)

Arguments

...

Code Block
languagejs
var daysGained = $Database.Get({
    Parameters : {
        TargetSchema : 'HR',
        TargetTable : 'LeaveAllowance'
    },
    Columns : [{
        Name : 'DaysGained',
        Expression : "Sum(DaysGained)"
    }],
    Start : 0,
    MaxLength : 1,
    Where : {
        Criteria : [{
            Name : 'Employee',
            Value : $Initiator.Id
        }]
    }
});

$Xml.SetValue('GeneralInfo/EarnedDays', daysGained.Rows()[0]["DaysGained"]);

// OR

totalLeaves.Each(function () {
    $Xml.SetValue('GeneralInfo/EarnedDays', this.DaysGained);
});

Example

Query with Expression - Advanced

js
Code Block
language
var offerCountByDayTable = $Database.Get({
    Parameters : {
        TargetSchema : 'OFR',
        TargetTable : 'Offers'
    },
    Columns : [{
        Name : "Day",
        Expression : "DateTrunc('Day', OfferDate)"
    },
        {
            Name : "Amount",
            Expression : "Count(DateTrunc('Day', OfferDate))"

        }],
    Order : [
        {Name : "DateTrunc('Day',OfferDate)", Type : 'Ascending'}
    ]
});

offerCountByDayTable.Each(function () {
    console.
(this.Amount + ' offers made on the date ' + this.Day.toISOString()); });
Info

Examples

...

var myTable = $Database.Get({ Parameters : { TargetSchema : 'HR', TargetTable : 'Groups' }, Where : { Criteria : [ { Name : 'Name', Value : 'Administrators' } ] }, Order : [ {Name : 'Order', Type : 'Ascending'} ] });
Code Block
languagejs

In the example below

...

Code Block
languagejs
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'}
    ]
});

...

Code Block
languagejs
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'
        }]
    }
});

...

Code Block
languagejs
var daysGained = $Database.Get({ Parameters : { TargetSchema : 'HR', TargetTable : 'LeaveAllowance' }, Columns : [{ Name : 'DaysGained', Expression : "Sum(DaysGained)" }], Start : 0, MaxLength : 1, Where : { Criteria : [{ Name : 'Employee', Value : $Initiator.Id }] } }); $Xml.SetValue('GeneralInfo/EarnedDays', daysGained.Rows()[0]["DaysGained"]); // OR totalLeaves.Each(function () { $Xml.SetValue('GeneralInfo/EarnedDays', this.DaysGained); });

, offers by suppliers are grouped by the day they made with their count.

Example

Query with Expression - Advanced

Code Block
languagejs
var offerCountByDayTable = $Database.Get({
    Parameters : {
        TargetSchema : 'OFR',
        TargetTable : 'Offers'
    },
    Columns : [{
        Name : "Day",
        Expression : "DateTrunc('Day', OfferDate)"
    },
        {
            Name : "Amount",
            Expression : "Count(DateTrunc('Day', OfferDate))"

        }],
    Order : [
        {Name : "DateTrunc('Day',OfferDate)", Type : 'Ascending'}
    ]
});

offerCountByDayTable.Each(function () {
    console.info(this.Amount + ' offers made on the date ' + this.Day.toISOString());
});

See Also