Class: JobSchedules

$.jobs. JobSchedules

$.jobs.JobSchedules Allows manipulation of a job's schedules. Properties below are only visible when schedules object is accessed as array object (e.g., schedules[id]).

new JobSchedules()

A scheduled job's schedules. Properties below are only visible when schedules object is accessed as array object (e.g., schedules[id]).
Properties:
Name Type Description
active Boolean A schedule's status can be active (true) or inactive (false).
description String Description of a schedule.
parameter String | object Parameter object or JSON string to be passed to schedule.
xscron String Xscron string of a schedule.
logs $.jobs.JobLog Provides access to log entries of a job's schedules.
Example
// Note: Manipulating a schedule via properties does not change the schedule id.
for (var id in myjob.schedules) {
    // set new description
    myjob.schedules[id].description = "New description";
    // set new parameter as JSON string
    myjob.schedules[id].parameter = "{\"a\":\"b\"}";
    // set new parameter as object
    myjob.schedules[id].parameter = {a:"b"};
    // set new xscron value
    myjob.schedules[id].xscron = "* * * * * * *";
    // set new status
    myjob.schedules[id].active = true;
}

Methods

add(parameters) → {integer}

Used to add a schedule to a job.
Parameters:
Name Type Description
parameters $.jobs.JobSchedules~AddParameters parameter object
Throws:
Throws an error if the parameters object is not valid or the execution fails.
Returns:
ID of the created schedule
Type
integer
Example
var id = myjob.schedules.add({
    description: "Added at runtime, run every 10 minutes",
    xscron: "* * * * * */10 0",
    parameter: {
        a: "c"
    }
});

delete(parameters) → {boolean}

Used to delete a schedule from a job.
Parameters:
Name Type Description
parameters $.jobs.JobSchedules~DeleteParameters parameter object
Throws:
Throws an error if the parameters object is not valid or the execution fails.
Returns:
True if the schedule has been deleted, false otherwise
Type
boolean
Example
myjob.schedules.delete({id: id});

deleteAll(filter) → {integer}

Used to delete all schedules from a job.
Parameters:
Name Type Argument Description
filter object <optional>
filter oject that restricts deleted schedules to ones that match filter
Properties
Name Type Argument Description
active boolean <optional>
True deletes only schedules with status active. False deletes only schedules with status inactive
designtime boolean <optional>
True deletes only schedules with origin designtime. False deletes only schedules with origin runtime
Throws:
Throws an error if the filter object is not valid or the execution fails.
Returns:
Number of schedules that has been deleted
Type
integer
Example
myjob.schedules.deleteAll({active: true, designtime: true});
myjob.schedules.deleteAll();

Type Definitions

AddParameters

Type:
  • object
Properties:
Name Type Argument Description
xscron string xscron string defining when the schedule should run
description string <optional>
describes the schedule
parameter object | string <optional>
object or JSON string that will be passed to the job's action. In case the action is a SQLScript, the structure of the object must match that of $.jobs.JobSchedules~AddSqlScriptParameters

AddSqlScriptParameters

Object that will be mapped to input parameters of SQLScript procedures. The mapping uses the parameter name of the SQLScript procedure. These mappings via the parameter name of a SQLScript procedure are marked with '{}' for this object. Default input parameters of SQLScript procedures are supported. Output parameters are not supported. Parameter names may be specified in any order.
Type:
  • Object
Properties:
Name Type Argument Description
{scalarString} String <optional>
possible for each parameter name of the SQLScript procedure with the following scalar SQLScript types: TINYINT, SMALLINT, INTEGER, BIGINT, VARCHAR, NVARCHAR, VARBINARY, DATE, TIME, TIMESTAMP, SECONDDATE, DOUBLE, REAL, FLOAT, DECIMAL, SMALLDECIMAL, CLOB, NCLOB, BLOB
{scalarNumber} Number <optional>
Number is additionally supported for the following scalar SQLScript types: TINYINT, SMALLINT, INTEGER, DOUBLE, REAL, FLOAT
{tableArray} Array <optional>
possible for each parameter name of the SQLScript procedure with table type. Each item of the array is inserted as a row into a newly created local temporary table. This local temporary table is visible only within the connection and is destroyed on exit of the XS Job
Properties
Name Type Argument Description
{rowIndex} Object <optional>
object uses table parameter names to map input strings to columns of the table and insert the strings
Properties
Name Type Argument Description
{scalarString} String <optional>
possible for each scalar input parameter name of the table with the following scalar SQLScript types: TINYINT, SMALLINT, INTEGER, BIGINT, VARCHAR, NVARCHAR, VARBINARY, DATE, TIME, TIMESTAMP, SECONDDATE, DOUBLE, REAL, FLOAT, DECIMAL, SMALLDECIMAL, CLOB, NCLOB, BLOB
{scalarNumber} Number <optional>
Number is additionally supported for the following scalar SQLScript types: TINYINT, SMALLINT, INTEGER, DOUBLE, REAL, FLOAT
{tableObject} Object <optional>
possible for each parameter name of the SQLScript procedure with table type. Parameter name establishes binding between object and SQL procedure parameter. Object defines table name and schema
Properties
Name Type Argument Description
table_name String name of the table
schema_name String <optional>
name of the schema that holds the table
Examples
// Example1: pass scalar parameters to a SQLScript procedure
// Prerequisite: SQLScript procedure exists, is referenced in the job action and is defined as follows:
// procedure "SCHEMA_NAME"."PACKAGE_NAME::PROC_SCALAR" (
//    IN DATEPARA DATE,
//    IN TIMESTAMPPARA TIMESTAMP,
//    IN DOPARA DOUBLE,
//    IN INTPARA INTEGER,
//    IN BIGINTPARA BIGINT)
// language SQLSCRIPT ...
"parameter": {
    "DATEPARA": "2013-01-30",
    "TIMESTAMPPARA": "2011-05-11 12:01:59.987654",
    "DOPARA": 5.0,
    "INTPARA": 5,
    "BIGINTPARA": "5"
}
// Example2: pass existing table as parameter to SQLScript procedure
// Prerequisites:
//     (1) table exists and matches the table type of the parameter name of the SQLScript procedure,
//     (2) SQLScript procedure exists, is referenced in the job action and is defined as follows:
// procedure "SCHEMA_NAME"."PACKAGE_NAME::PROC_TABLE" (
//    IN TABLE_PARAMETER_NAME "SCHEMA_NAME"."PACKAGE_NAME::TABLETYPE1")
// language SQLSCRIPT ...
// table "SCHEMA_NAME"."PACKAGE_NAME::TABLE1" like type "SCHEMA_NAME"."PACKAGE_NAME::TABLETYPE1"
"parameter": {
    "TABLE_PARAMETER_NAME": {
        "table_name": "PACKAGE_NAME::TABLE1",
        "schema_name": "SCHEMA_NAME"
    }
}
// Example3: create and fill local temporary table and pass to SQLScript procedure
// Prerequisites:
//     (1) table type exists,
//     (2) SQLScript procedure exists, is referenced in the job action and is defined as follows:
// procedure "SCHEMA_NAME"."PACKAGE_NAME::PROC_TABLE" (
//    IN TABLE_PARAMETER_NAME "SCHEMA_NAME"."PACKAGE_NAME::TABLETYPE1")
// language SQLSCRIPT ...
// type "SCHEMA_NAME"."PACKAGE_NAME::TABLETYPE1" as table (INTPARA INTEGER, TSPARA TIMESTAMP)
// will create a local temporary table with name "#TABLE_PARAMETER_NAME" that contains two rows:
"parameter": {
    "TABLE_PARAMETER_NAME":
        [{"INTPARA": "23", "TSPARA": "2014-10-30 17:21:36"},
         {"INTPARA": "24", "TSPARA": "2014-10-30 18:21:36"}]
}

DeleteParameters

Type:
  • object
Properties:
Name Type Description
id integer id of the schedule to delete