Script Function: It returns the value of a Variable objectAutomation Engine controlled activities and processes are structured in the form of objects. See also: Task.
GET_VAR(Variable, [Key, Column], [XPath/XQuery])
Syntax |
Description/Format |
---|---|
Variable |
The name of a Variable object whose value should be retrieved. |
Key |
The variableIt stores or retrieves values dynamically at runtime. An individual Automation Engine object type. line for the value retrieval (entry of the Key / first value column).
|
Column |
The number of the column whose value should be used. Allowed values: |
XPath/XQuery |
Use an XPath or XQuery expression to access and read out the nodes or content of XML data. This functionPre-defined run book template in the Automation Engine. One single step only, e.g. Start Windows Service, Copy file,… may be used with the static Variable object XML only. The use of XPath expressions with the Variable object XML is possible, but depending on the databaseA database is an organized collection of data including relevant data structures. the Automation EngineThis component drives an Automation Engine system and consists of different types of server processes. system is being used with, individual XPath expressions may work differently. In such cases please check with the database's vendor. |
Return Codes |
---|
Variable's value(s)
|
You can use this scriptA particular Automation Engine object type. function in order to read the values of static and dynamic Variable objects. Accessing a dynamic variable has the effect that the value will be resolved. This means that the value is directly retrieved from the data source (database, variable, directory).
An error that occurs while dynamic Variable objects are being resolved results in a runtimeThe duration of a task's execution. It refers to the period between a task's start and end. It does not include its activation period (see also: activation and start). error.
If a key is not specified for a static Variable object, the system automatically selects the key based the Scope setting on the Attributes tab of the Variable object. In all other cases where the Key is not specified, the first line is used. Note that you must always specify the key in static Variable objects in which the scope "Freely selected" is selected.
If the Column is also missing, the system will automatically use the Value 1 column (for static Variable objects), the result column (variable source: SQL, SQL-internally, multi) or the Filelist column (variable source: Filelist).
In variables that use the source "Filelist", you can either skip the column or use the value 1. The specified key complies with the returned value because there is only one column.
The area between 1 (first value column) and the last column number can be used as the value for the Column. You can use the value RESULT for the Column in order to read the result column (dynamic variablesA Variable object with the attributes "Source" - "EXEC", "SQL", "SQL internal", "Multi" or "Filelist". Values are directly retrieved from the data source and not stored in the object. except "Filelist"). Note that static variablesA Variable object with the setting "Source" - "Static": Variable values are entered by a user or with a script and remain stored in the object. have only 5 value columns. Using this script function in combination with :FILLhas the effect that all values of a line will be written to a script array.
The value's format corresponds to the output format that has been defined in the Attributes tab.
This script function can also be used to read agentA program that enables the de-centralized execution of processes (such as deployments) on target systems (computers or business solutions) or a service that provides connectivity to a target system (such as for databases or middleware). An agent is also an object type in the Automation Engine. [Formerly called "Executor."] See also: host variables.
To access a key that begins with a "&" character, you must use this character twice. Otherwise, this term will be interpreted as a script variable and the system will try to resolve it.
For example: Access the key "&key" in the Variable object VARA.TEST
:SET &TEST# = GET_VAR(VARA.TEST,"&&key")
A blank will be returned when you use GET_VAR for a key that does not exist.
In dynamic variables, you must specify the value of the result column (parameter Line) in the format that it shows in the data source (SQL - database, MULTI - Variable object). The variable's output format is irrelevant in this case.
In static variables, you can also use the specific value "KEY" for the column. You can use it in order to check whether a certain key exists in this Variable object. It does not exist when the script function returns an empty value and there is an entry when it returns the key.
In the following example, the script function returns "Test" when there is a key and " " when there is no key:
:SET &KEY# = GET_VAR(VARA.TEST, "Test","KEY")
When using this script function with the static Variable object XML, the values for XML data type will be beautified automatically. That means, you may use XML in a single script line for example, but in the resulting script output the value will be rearranged according to the XML standard.
The following example retrieves the value of a variable and stores the result in a script variable:
:SET &TEST# = GET_VAR(MM.END.PROCESSING, "BookingDate")
Script variables can also be used in functions:
:SET &VAR# = "MM.END.PROCESSING"
:SET &VAL# = "BookingDate"
:SET &TEST# = GET_VAR(&VAR#, &VAL#)
In the following example, the script function GET_VAR is used to define a condition:
:IF GET_VAR(MM.END.PROCESSING,
"BookingDate") = SYS_DATE("DDMMYY")
!...
:ENDIF
See also:
Script element | Description |
---|---|
Deletes one or all values of a static Variable object. | |
:PUT_VAR | Stores a value in a static Variable object. |
:SET_SCRIPT_VAR | Sets the values of script variables by indirect access. |
GET_SCRIPT_VAR | Returns the values of script variables by indirect access. |
|
|
Prepares the processing of a data sequenceAn internal listing of Console outputs or lines of Variable objects, etc. The lines of a data sequence can be accessed by using a PROCESS loop or the script element GET_PROCESS_LINE. The script elements PREP_PROCESS* generate data sequences. (values of a Variable object). |
Script Elements - Read or Modify Objects
Sample Collection:
Database Maintenance with Options
Calling an MBean
About Scripts
Script Elements - Alphabetical Listing
Script Elements - Ordered by Function
Automic Documentation - Tutorials - Automic Blog - Resources - Training & Services - Automic YouTube Channel - Download Center - Support |
Copyright © 2016 Automic Software GmbH |