The SQL driver for Invantive Script exposes the execution profile of the script being run: the runs performed, the statements executed, the scripting variables defined and the operating-system commands started on behalf of the script. It allows a script to report on itself, so that the duration and the outcome of each statement can be queried with SQL instead of being read back from a log file afterwards. Available from release 26.0. The driver covers 4 tables and 69 columns. ## Specifications The SQL driver for Invantive Script does not support partitioning. An introduction into the concepts of Invantive UniversalSQL such as databases, data containers and partitioning can be found in the [[Grammar|Invantive UniversalSQL grammar]]. The driver is a service driver, so the connection is always present in a database and occurs at most once. No data container is defined for it in [[Settings]] and no log on takes place. The driver has the following properties: - Recommended alias: `script` - Catalog: `Script` - Technical support (URL): https://forums.invantive.com ## Scope of the Profile The profile covers the process in which the statements run. It is held in memory and starts empty each time the product is started, so a query returns the runs and statements of the current process only and never those of an earlier one. A query on the profile is itself a statement and therefore appears in its own results, with the columns describing its outcome still empty because it has not ended yet. A statement executed on its own, such as the statement under the cursor in Invantive Query Tool, forms a run of one statement with `SOURCE_KIND` set to `INTERACTIVE`, so `Runs@script` holds one row per such execution. Statements executed together as a script share one run. The profile is filled by the product running the script. It is available in the products which carry Invantive Script, such as Invantive Data Hub and Invantive Query Tool; a product which executes statements without Invantive Script leaves the profile empty. See [[Invantive Script/Invantive Script|Invantive Script]] for the language itself. Statements which handle a secret are registered without their text. The text of a statement such as a definition of an encrypted variable is replaced by `(anonymized)` and the column `IS_ANONYMIZED` reads `true`; the hash in `STATEMENT_HASH` is still filled, so identical statements remain comparable without the secret being retained. ## Objects Per object category a list is available: - [[Invantive UniversalSQL/Service Drivers/Invantive Script Data Model/Tables/Tables|Tables]] ## Examples The following example lists the statements of the current run from slowest to fastest: ```sql select sen.statement_type , sen.sql_operation , sen.duration_ms , sen.rows_affected , substr(sen.statement_text, 1, 60) statement_text from StatementExecutions@script sen where sen.ended_utc is not null order by sen.duration_ms desc ``` The following example reports the statements which failed, together with the reason: ```sql select sen.id , sen.statement_type , sen.error_message_code , sen.error_message from StatementExecutions@script sen where sen.successful = false order by sen.id ``` The following example totals the time spent per kind of statement: ```sql select sen.statement_type , count(*) statements , sum(sen.duration_ms) duration_ms from StatementExecutions@script sen group by sen.statement_type order by duration_ms desc ```