.. _blue_scripting: ************** Blue Scripting ************** The Java- based Blue scripting enhances your interaction with SQL by providing conventions which allow dynamic generation, management, and automation of SQL code and database operations. Syntax ====== .. code-block:: postgres -- Parallel: @@ Parallel $$ ... $$ -- Declare: @@ Declare '' = -- SetResults: @@ SetResults -- SplitQueryByDateTime @@ SplitQueryByDateTime instances = , from = , to = -- SplitQueryByDate @@ SplitQueryByDate instances = , from = , to = -- SplitQueryByNumber @@ SplitQueryByNumber instances = , from = , to = -- ${ ... } .. list-table:: :widths: auto :header-rows: 1 * - Parameter - Description * - ``Parallel`` - Runs specified queries in parallel * - ``Declare`` - Declares a variable value * - ``SetResults`` - Saves specified query results as a variable * - ``SplitQueryByDateTime`` - Splits query execution by a predefined number of instances and by specific ``DATETIME`` column values * - ``SplitQueryByDate`` - Splits query execution by a predefined number of instances and by specific ``DATE`` column values * - ``SplitQueryByNumber`` - Splits query execution by a predefined number of instances and by specific ``NUMERIC`` column values Usage Notes =========== .. glossary:: **Execution** Metalanguage scripting is available only through the Blue web interface and cannot be used via the CLI. ``Parallel`` The performance of the ``Parallel`` parameter depends on the number of Workers allocated to the resource pool you are operating through. Examples ======== ``Parallel`` ------------ .. code-block:: cry @@ Parallel $$ SELECT * FROM my_table; SELECT * FROM our_table; SELECT * FROM that_table; $$; ``Declare`` ----------- .. code-block:: plpgsql @@ Declare myVar = 3; SELECT '${myVar}'; ``SetResults`` -------------- .. code-block:: cry @@ SetResults tableAverage SELECT AVG(col1) AS avg_salary FROM my_table; SELECT col1 FROM my_table WHERE col1 > ${tableAverage[0].avg_salary}; ``SplitQueryByDateTime`` ------------------------ .. code-block:: plpgsql @@ SplitQueryByDateTime instances = 4, from = '2021-01-01 00:00:00', to = '2022-01-01 00:00:00' SELECT ${from}, ${to}; ``SplitQueryByDate`` -------------------- .. code-block:: plpgsql @@ SplitQueryByDateTime instances = 4, from = '2021-01-01', to = '2022-01-01' SELECT ${from}, ${to}; ``SplitQueryByNumber`` ---------------------- .. code-block:: cry @@ SplitQueryByDateTime instances = 4, from = 0, to = 100 SELECT ${from}, ${to};