LIB RUN

Core command LI RU LIRU

Executes a SQL query stored in the queries library

Arguments

<name> (mandatory) a file name, @alias, or search term. Default extension is SQL

Examples

LIB RUN COUNTRY.SQL

Notes

Runs a saved query from the SQL library: LIB RUN <name> [param1 param2 ...].

name is mandatory, matched against the file's relative path, a declared @alias, or (if unambiguous) its bare file name; the .sql extension is appended automatically if omitted and nothing else matched. The entry's content is read from the configured library folder (SqlLib in BroadSQL.ini), its metadata header stripped, echoed to the console, and executed: as a SELECT if it isn't recognized as an update statement, as an update otherwise.

The stored query may contain positional placeholders %1 to %9, replaced by the extra arguments given after the name, in order (e.g. LIB RUN MYQUERY.SQL CH 800 replaces %1 with CH and %2 with 800). If any placeholder is still present after substitution, the command reports that not enough parameters were given and does not run the query; if more arguments are given than the query actually uses, it reports that too but still runs it. The <@file> macro syntax (see HELP) is only expanded for SELECT-type queries, not for updates. Also prints a one-line warning, without refusing to run, for each of the entry's @instance/@environment metadata that doesn't match the current connection's instance/environment (see docs/SQL_LIBRARY_AND_SCRIPTS.md, sections 4 and 7).

Last modified in release 5.0.8.