Assignment Statements
Notice
Compared with the original openGauss, Dolphin modifies the assignment syntax as follows:
- The syntax function of assigning values to variables through set is added between BEGIN and END.
Syntax
Figure 1 shows the syntax diagram for assigning a value to a variable.
The following is supported in B-compatible mode:
set variable_name := value;
The syntax is described as follows:
- variable_name indicates the name of a variable.
- value can be a value or an expression. The type of value must be compatible with the type of variable_name.
Example:
openGauss=# DECLARE
emp_id INTEGER := 7788; -- Assignment
BEGIN
emp_id := 5; -- Assignment
emp_id := 5*7784;
END;
/
In B-compatible mode:
openGauss=# DECLARE
emp_id INTEGER := 7788; -- Assignment
BEGIN
set emp_id := 5;-- Assignment
set emp_id := 5*7784;
END;
/
NOTICE:
- You can run the set variable_name :=(=) value command to assign a value to a variable between BEGIN and END.
Feedback