HomeMogDBMogDB StackUqbar
v5.0

Documentation:v5.0

Supported Versions:

Other Versions:

Assignment Statements

Notice

Compared with the original openGauss, Dolphin modifies the assignment syntax as follows:

  1. 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.

Figure 1 assignment_value::= assignment_value

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:

MogDB=# DECLARE
    emp_id  INTEGER := 7788; -- Assignment
BEGIN
    emp_id := 5; -- Assignment
    emp_id := 5*7784;
END;
/

-- In B-compatible mode:
MogDB=# DECLARE
    emp_id  INTEGER := 7788; -- Assignment
BEGIN
    set emp_id := 5; -- Assignment
    set emp_id := 5*7784;
END;
/

img NOTICE:

  • You can run the set variable_name :=(=) value command to assign a value to a variable between BEGIN and END.
Copyright © 2011-2024 www.enmotech.com All rights reserved.