simpledeclaration

NAME
SYNTAX
DESCRIPTION
SCALAR VARIABLES
GLOBAL VARIABLES
EXAMPLES
COPYRIGHT
SEE ALSO

NAME

simpledeclaration − RWP*Load Simulator simple declarations

SYNTAX

simpledeclaration ::=
[ private ]
( scalardeclaration | sqldeclaration | lobdeclaration )


scalardeclaration ::=
(
  string [ ( expression ) ] [ threads global ]
  | integer [ threads ( sum | global ) ]
  | double [ threads ( sum | global ) ]
  | file
)
(
  identifier
  | identifier := concatenation
)
{ , ( identifier | identifier := concatenation ) }

DESCRIPTION

Declares simple variables, which includes variables of type integer, double, string, clob, file in addition to SQL statements. All such variables can be declared publicly, privately (using the private keyword) and locally within a procedure, function or execution block. Public variables are available in all rwl input files, private variables are available only within the file where they are declared.

Declarations without the private keyword are public when found outside procedures or functions, and are local when declared inside procedures or functions including implicitly created procedures.

SCALAR VARIABLES

Scalar variables are the simple ones of type integer, double or string. Unless they are assigned to at the declaration, they will be initialized to null for integer and double or the empty string respectively. A string is (with very few exceptions) never null in rwloadsim. By default, when threads are started using the run statement, public and private variables will have their current value.

integer, double

Declare a variable of type integer our double. Such variables can be null (as in the Oracle database) and will be null until explicitly assigned. If a public or private variable is declared with threads sum, it will be initialized to zero when threads are started, and the value from all threads will be added to the variable in main when threads complete.

string ( N )

Declare a string variable with a maximum length in bytes. If the parenthesis and a length are not provided, the default is 128 bytes. The length must be an expression that is available during parsing, so it cannot use local variables. Note that at present, rwloadsim has no concept of national characters so strings are sequences of bytes terminated by null. You can, however, very well use national characters in strings. Strings are, with very few exceptions, never null.

GLOBAL VARIABLES

Variables of type integer, double and string can be declared with the threads global attribute. This implies the variable does not exist separately in each thread, and that every access to the variable is to the single variable found in the main program. All such access is using a mutex that protects internal rwloadsim structures. This does not prevent race conditions in your rwloadsim code, and if you e.g. attempt something like

double threads global a;
run
  threads ..
    a := a*2;
  end;
end;

the assignment to the variable a and the access to it in the expression are not done under a single mutex. The purpose of threads global variables is to allow one thread to change values that are being used in another thread. Due to the overhead of the mutex, they should be used sparingly.

EXAMPLES

integer a,b,c := 20;
string(22+c) fortytwo;

Declare three integer variables and assign the value 20 to the last of these; declare a string variable with length 42.

double threads sum total;

Declare a double variable which in threads will be initialized to 0.0 and have the value from all threads summed into the variable in main after thread completion.

string(30) person := "Garçon";

Declare a string of maximum size 30 bytes and assign a value to it containing a national character. Note that actual length (in bytes) after the assignment will depend on the actual character set being used; as an example, if your character set is UTF8, the length in bytes will be 7.

COPYRIGHT

Copyright © 2023 Oracle Corporation
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl

SEE ALSO

expression(1rwl), filestatement(1rwl), sqldeclaration(1rwl), lobdeclaration(1rwl), randomstringdeclaration(1rwl)