System Functions
System functions provide access to information in the CData Virtuality Server system via a query. Here's an overview of them:
To view the full table, click the expand button in its top right corner
Function | Description | Return value type |
---|---|---|
CALLER() | Retrieves the name of the user executing the query. For jobs: when For procedures: when | String |
CURRENT_DATABASE() | Retrieves the catalog name of the database | String |
DV_SESSION_SET('name', value) | Sets the indicated session variable to the indicated value | Object |
DV_SESSION_GET('name') | Retrieves the value (null if no value has been set) | Object |
ENV('key') | Retrieves the system (i.e. CData Virtuality Server) property specified by key | String |
SESSION_ID() | Retrieves current session ID in string form | String |
REQUEST_ID() | Retrieves the current request ID | Long |
USER() | Retrieves the name of the user owning the query | String |
LASTUPDATED('fqn') | Retrieves the oldest materialization timestamp from all query components. fqn can be the fully qualified name of a table/view or column. Returns Example:
| Timestamp |
Calling any system function is very simple - here's how to run USER()
, for example:
SELECT USER();;
USER()
and user()
will work.
Special Note on ENV('key')
One important thing to remember about this function is that it is not enabled by default for security reasons to prevent untrusted access to system properties. To enable it, you'll need to use the following command and restart the CData Virtuality Server:
CALL SYSADMIN.executeCli('/subsystem=teiid:write-attribute(name=allow-env-function,value=true)');;
Special Note on DV_SESSION_SET('name', value) and DV_SESSION_GET('name')
Unlike other system functions described above, these two go together, and their purpose is to set and read variables at the session level.
The first function sets the indicated variable to the indicated value and returns the old value, and the second retrieves the current value (if no value has been set previously, null will be returned). Variables are key-value pairs; the name is a string, the value and the return value are objects.
A special case is the dv.maxRecursion
session variable: it is a session variable per se, with a fixed default value which can be modified using DV_SESSION_SET('name', value)
:
SELECT DV_SESSION_SET('dv.maxRecursion', 25);;
CALLER
function is available since v4.1
USER
function is nondeterministic since v4.1