Script directives

The first lines of a Script may declare what it is and what it takes, in -- comments. These lines are directives: BroadSQL reads them to check arguments, warn about the connection, and list or search Scripts. Each row links to the section that explains it in full.

-- @description: Largest countries of a continent
-- @instance: WORLD_APP
-- @environment: ALL
-- @tags: geo, reference
-- @status: stable
-- @access: read
-- @dialect: H2
-- @param continent TEXT "Continent, as in COUNTRY.CONTINENT"
-- @param min_population INTEGER = 50000000 "Smallest population listed"
SELECT CODE, NAME, POPULATION FROM COUNTRY
 WHERE CONTINENT = ${continent} AND POPULATION >= ${min_population};
FormWhat it doesExampleDetails
-- @param <name> <type> [= <default>] ["<description>"]Declares one typed parameter: TEXT, INTEGER, DECIMAL, BOOLEAN, DATE, TIMESTAMP or LIST OF <type>. With a default it is optional.-- @param min_population INTEGER = 50000000Typed parameters
-- @params: <name>, ...Lists the arguments every call must pass, without types. Prefer -- @param for a new Script.-- @params: country, min_idRequired arguments
-- @description: <text>A one-line description, shown by search and in the Editor.-- @description: Monthly revenue by countryMetadata header
-- @instance: <group>[, ...] | ALLThe Database Group(s) the Script is about. A mismatch with the current connection prints a warning; nothing is blocked.-- @instance: WORLDAPPWhat @instance and @environment do
-- @environment: <environment>[, ...] | ALLThe Environment(s) the Script applies to. A mismatch prints a warning; nothing is blocked.-- @environment: PRODWhat @instance and @environment do
-- @tags: <tag>, ...Free text tags, matched by LIB FIND and grouped by LIB LIST ... BY TAG.-- @tags: finance, monthlyMetadata header
-- @status: draft | stable | deprecatedInformation only, shown in listings.-- @status: stableMetadata header
-- @access: read | writeDeclares whether the Script changes data. Never enforced; LIB LINT reports a read Script that may write.-- @access: readWhat @access and @dialect do
-- @dialect: <type>[, ...] | ANYThe connection types the Script is written for. On another type, BroadSQL warns and runs it anyway.-- @dialect: PostgreSQL, H2What @access and @dialect do

Rules for every directive

  • Both -- @key value and -- @key: value work, in -- line comments or /* ... */ block comments.
  • @instance, @environment, @tags, @dialect and @params may be repeated to add values; @param is written once per parameter. For another key written twice, the first one wins.
  • Only @param and @params can refuse a call. @instance and @environment print a warning on a mismatch and scope what LIB LIST shows; @dialect prints a warning; @access is checked by LIB LINT only.
  • @instance names a Database Group: the name predates the Database Group rename and is kept in the file format.

Check a header

LIB SHOW <script>; prints the declared parameters, access and dialects; LIB LINT; reports unknown Database Groups, Environments and dialects, unreadable @param lines, and read Scripts that may write.

Found something wrong or unclear on this page? , with the page address.