Language Basics

[ Home / SQLBatch Home / Documentation / Basics ]


 Terms and definitions

SB stands for SQL Batch

SB also means SQL Batch Language

Code block is a construction of the following syntax: {# SB operator} or { SB expression}

 SB expressions

SB expands (evaluates) all code blocks with SB expressions before executing the SQL script. The result is treated as a string and splited into lines and they are substituted in place of the expression.

Expressions are evaluated as late as possible. This means that if execution of the script is interrupted at the middle of the file, for instance by EXIT command, the expressions, which follow after this command will not be executed.

If the last nonspace symbol of the expression is ';' then expression is only evaluated but not substituted. This is useful for assignments.

You can specify many expressions in a block code. They are all evaluated and the result of the block is the result of the last expression unless it is followed by ';'.

Here are simple examples:

SQL> {count=5;} -- variable COUNT becomes 5, result is an empty SQL line
SQL> prompt Count: {(count+5) . ' units'} -- point (.) is a concatenation operator
Count: 10 units

Cursor variable example (you should have been already connected):
SQL> prompt {curs = sql "select user from dual"; curs->user}
SYSTEM

SEE ALSO:
Variables
Special Variables

 Execution control operators

Execution control operators never return a result. However they can change order and number of executions for a group of SQL commands.

SB operators can be used with single or multiple SQL lines and can be nested.

SB operator is expanded before execution of the enclosed SQL code. So, if you run an infinite loop like the following, then no one SQL command will be executed until loop is expanded, that is no one SQL command will ever be executed:
{#while 1}
insert into some_tab values (1);
{#end}
Here you need Ctrl-C.

There are the following operators:

See Also
#FOR operator
#WHILE operator
#IF operator
Variables
Special Variables


Copyright (C) 1999 - 2024 Anatoly Moskovsky Report a site problem