Defining DB Event Objects
You define DB (Database) Events to monitor and compare two values in the database. If the conditions you define on the Event Process page are met, the DB Event triggers the actions you coded on its Event Process page. These actions are usually the execution of further objects. DB Events are in Sleeping status as long as the frequency and time conditions are not met and change to Checking when they are.
You can use the following functions of the Automic scripting language to retrieve relevant data for the Event object:
- For Console, File and Database Events: GET_CONSOLE, GET_EVENT_INFO
- For Windows Events: GET_WIN_EVENT
You define DB Event objects on two pages:
-
Database Event
Here you define the values to be compared.
-
This is the core of Event objects. You specify here the statements that are processed as soon as the defined conditions are met.
To Define DB Event Objects
-
Define the values to be compared.
On the Database Event page you define the two values that should be compared and the operator that compares them.
Three sources can provide the values:
Source Description SQL Query You can use Object variables within an SQL query. The database event does not abort if the query is incorrect.
- In Source select SQL Query to display the SQL-specific input fields.
-
In SQL click the file icon on the right hand side to open the Cell Editor, where you can enter the SQL query.
Click OK.
-
In Agent enter the name of the database agent that processes the query. It can be up to 4096 characters long.
Agent groups cannot be selected in database events
- In Login select the object that contains the necessary information for the event to be able to log on to the system.
-
In Server:Port enter the name of the computer on which the database is available, for example PC01:2281.
The default ports are:
- MS SQL Server: 1433
- Oracle: 1521
- DB2: 50000
- MySQL: 3306
Do not complete this field if the query should be made in an Oracle database in RAC.
- In Database enter the name of the database.
- In MS Access Filename enter the path and file name of the MS Access database.
Static Value Enter any value; It can contain up to 40 characters. Variable - In Variable Object select the name of the Variable object that contains the string to compare.
- In Variable key select the entry in the Variable object to be used for the comparison.
The database event is not activated if the key does not exist in the specified Variable object.
If the key does not include a value, the result depends on the setting that has been defined on the Attributes Page of the Variable object. The system either logs an error message or uses the initial values. The database event does not abort.
See GET_CONSOLE, GET_EVENT_INFO for details on the syntax of event handling scripts.
-
Compare the values.
Select the Operator to use in the comparison. The following options are available:
- > Greater than
- < Less than
- = Equal to
- != Not equal to
- >= Greater than or equal to
- <= Less than or equal to
- Contains
You can combine values as necessary. Values are interpreted and compared as string values; if both values can be interpreted as positive integers (>=0), they will be compared as integer values.
For example:
5 > 1: Values are interpreted as positive integers -> int 5 > int 1 -> true
1 > -1: Values are interpreted as strings -> string "1" > string "-1" -> false
Fractional digits are truncated. To prepare them for comparison first read the values on the Event Process page using the GET_CONSOLE, GET_EVENT_INFO script function and then multiply them with 10n in order to move the commas.
For example:
4 * 100 (corresponds to 102) = 12344
123.5555 * 10000 (corresponds to 104) = 12355555
Time stamps of SQL queries and Variable objects are converted to "YYYY-MM-DD HH:MM:SS".
-
Define the Time Parameters.
Field Description Frequency Select the option that determines how often the event object should be activated:
-
Once
It is activated only once.
-
Repeatedly
It is activated periodically, depending on the setting you define below.
-
Repeat until first match
It is activated until the specified conditions applies.
Check Frequency Specify when the event object will be activated:
-
Activate the In intervals of ... minutes to define a periodicity and enter or select the interval.
-
Activate At to define a specific time and enter it.
Some of the settings specified here can be read at runtime. Script elements are used to access the attributes of this object.
First Check Here you further configure when the intervals should begin:
-
Immediately
The Event object becomes active for the first time upon its activation, regardless of the specified time interval.
-
After the first interval
The Event object becomes active for the first time after the expiration of the first time interval.
If start time is later Here you further configure when the event should be activated:
-
Activate immediately
If the Event object starts after the specified time, it becomes active immediately.
-
Wait for the next valid date
If the Event object starts after the specified time, it becomes active with the next valid date considering the calendar and time conditions you specify below.
-
-
Define the Time and Date Conditions.
- Click the first row to activate it and, in the Calendar column select an entry from the dropdown list.
- Select the Calendar Event you want to apply.
-
To edit a row you must first click its checkbox to activate it. You have then the following options:
To add/edit a row you must first click its checkbox to activate it. You have then the following options:
Option Description
Inserts a new row at the bottom of the table
Deletes the row Removes the entry from the list and pastes it to the clipboard. Click Paste to add it to the bottom of the table. Duplicates the entry. Click Paste to add it to the bottom of the table. Activates all rows in the table.
-
Switch to the Event Process Page.
A database event process cannot contain JCL lines.
Next steps:
Define the Actions that the Event will Trigger
You do this on the Event Process Page.
Execute the Event Object
The execution of an Event object usually triggers the execution of other objects; those objects may in turn trigger the execution of further tasks. In the Process Monitoring perspective on the various lists of Executions related to the Event object, the tasks resulting from these executions are displayed as children of the Event and are flagged with a special tag type, namely !EVNT. This way you can easily check which executions were triggered by a specific Event.
See Monitoring Events for details on how the Event Monitor works as well as Execution Data for information on Execution data.
Event objects can be included in Schedule Objects (JSCH) and thus be executed automatically at predefined times and/or intervals. Likewise, they can be part of workflows (see Workflow Overview).
Of course, you can also manually execute, restart or stop them. For details see Executing Event Objects.
If you want to check the number of times the system checked the Event, go to the Check count section on its Details.
Monitor the Event
Immediately after executing the object you can start monitoring it. Right-click it to select Monitoring and open the pre-filtered list of tasks to display this one. See Monitoring.
In the Process Monitoring perspective you can then follow their progress and access the reports and statistical information associated to them.
Active Events can be canceled (they assume then the Abend/manually canceled status), quitted (they end cleanly with Ended_OK status) or suspended (this keeps the Event active but temporarily disabled).
See Working with Tasks, particularly Stopping and Interrupting.
See also: