Adjust your SQL code dynamically according to conditions
The logic blocks supports conditional execution through the use of if and else, allowing dynamic SQL code to be executed only when certain conditions are met.
The syntax of these conditions is as follows:
Includes the code only if the condition is true, without an alternative.
Allow two content alternatives. If the condition is not true, the content defined after {:else}
will be included.
Allow unlimited content alternatives. It evaluates conditions cascading until one is met. If none is met, it returns the content defined after {:else}
.
Expressions are crucial for determining the logic within if and else constructs. They can evaluate variables, constants, or any combination of the two using a variety of operators.
Values can be inside expressions:
param('user_id')
could be a query parameter representing a user’s ID. Check out Query Parameters for more information.
id
could be a variable representing a user’s ID. Check out Parameters for more information.
Complex operations can be performed within expressions:
Arithmetic Operations: Basic arithmetic operations can be performed within expressions.
String Operations: String operations can be performed within expressions.
Expressions are compared with operators, which include the following options:
==
: Equal to
!=
: Not equal to
>
: Greater than
<
: Less than
<=
: Less than or equal to
>=
: Greater than or equal to
&&
: Logical AND to concatenate multiple conditions in the same expression. They must all be true to continue.
||
: Logical OR to concatenate multiple conditions in the same expression. At least one of them must be true to continue.