SQL-like query language for csv

Control Flow

IF statements and WHILE statements create local scopes. Variables, cursors, temporary tables, and functions declared in statement blocks can be refered only within the blocks.

IF

IF condition THEN statements
  [ELSEIF condition THEN statements ...]
  [ELSE statements]
END IF;
condition
value
statements
Statements

A If statement executes the first statements that condition is TRUE. If no condition is TRUE, the statements of the ELSE expression are executed.

CASE

Case with condition

CASE
  WHEN condition THEN statements
  [WHEN condition THEN statements]
  [ELSE statements]
END CASE;
condition
value
statements
Statements

Execute statements of the first WHEN expression that condition is TRUE. If no condition is TRUE, then execute statements of the ELSE expression.

Case with comparison

CASE value
  WHEN comparison_value THEN statements
  [WHEN comparison_value THEN statements]
  [ELSE statements]
END CASE;
value
value
comparison_value
value
statements
Statements

Execute statements of the first WHEN expression that comparison_value is equal to value. If no comparison_value is match, then execute statements of the ELSE expression.

WHILE

WHILE condition
DO
  statements
END WHILE;
condition
value
statements
Statements

A While statement evaluate condition, then if condition is TRUE, executes statements. The While statement iterates it while condition is TRUE.

WHILE IN

WHILE [DECLARE|VAR] variable [, variable ...] IN cursor_name
DO
  statements
END WHILE;
variable
Variable
cursor_name
identifier
statements
Statements

A While In statement fetch the data from the cursor into variables, then execute statements. The While In statement iterates it until the cursor_name pointer reaches the last record in the referring view.

If DECLARE or VAR keyword is specified, then variables are declared in the child scope. Otherwise variables in the current scope is used to fetch.

CONTINUE

CONTINUE;

A Continue statement stops statements execution in loop, then jumps to the next iteration.

BREAK

BREAK;

A Break statement stops statements execution in loop, then exit from current loop.

EXIT

EXIT [exit_code];
exit_code
integer

0 is the default.

A Exit statement stops statements execution, then terminates the executing procedure without commit.

TRIGGER ERROR

TRIGGER ERROR [exit_code] [error_message];
exit_code
integer

64 is the default.

error_message
string

A trigger error statement stops statements execution, then terminates the executing procedure with an error.