Variables

[ Home / SQLBatch Home / Documentation / Basics ]


 Variables overview

All SB variables are global(with some exceptions). Variable names are case-independent.

There are 2 types of variables:

  • scalar
  • structure

A scalar variable stores a single string value. Scalars are initialized by assigning to them a value which can be a literal or an expression of scalars and literals.

A structure variable stores multiple named variables (fields) which can store scalars or structures. Structures can be initialized only by assigning values to their scalar fields.

There are keywords that cannot be used as variables' names (except for field names).

The keywords follow below:

chomp chop chr crypt index lc lcfirst length oct ord reverse sort rindex sprintf substr uc ucfirst abs atan2 cos exp hex int log oct rand sin sqrt srand or and not continue if while until unless last next redo delete exists ne eq EscStr Esc MapSchema MapSource q qw qq f d arg

 Syntax (in expressions)

Syntax 1 (scalar)

  • assigning: variable_name = expression ;
  • reading: variable_name
     where variable_name consists of letters, digits, underscores and begins with a letter or an underscore.
  • Syntax 2 (structure's field)

    structure_name->field_name->... ->field_name,
     where structure_name and field_name consists of letters, digits, underscores and begins with a letter or an underscore. The last field_name must be a scalar and all other names must be structures.

    Syntax 3 (part of string literal)

    Variables preceeded by colon(:) is interpolated inside doublequoted string literals:
    "some string:variable_name some string"

    See Also
    Language Basics
    Special Variables


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