3.2.4.10. Goldendb-mysql

3.2.4.10.1. 插入

3.2.4.10.1.1. 支持return/returning子句(一般用于PLSQL中静态SQL)

-- 转换前Oracle SQL:
INSERT INTO students VALUES ('John Doe', 20)  RETURNING employee_id, salary INTO @v_employee_ids, @v_salaries;
INSERT INTO students (name, age)  VALUES ('John Doe', 20)  RETURNING employee_id, salary INTO v_employee_ids, v_salaries;
INSERT INTO students (name, age)  VALUES ('John Doe', 20)  RETURN employee_id, salary INTO @v_employee_ids, @v_salaries;
INSERT INTO students (name, age)  VALUES ('John Doe', 20)  RETURN employee_id, salary INTO v_employee_ids, v_salaries;

-- 转换后GaussDB-Oracle SQL:
INSERT INTO students VALUES ('John Doe', 20)  RETURNING employee_id, salary INTO @v_employee_ids, @v_salaries;
INSERT INTO students (name, age)  VALUES ('John Doe', 20)  RETURNING employee_id, salary INTO v_employee_ids, v_salaries;
INSERT INTO students (name, age)  VALUES ('John Doe', 20)  RETURN employee_id, salary INTO @v_employee_ids, @v_salaries;
INSERT INTO students (name, age)  VALUES ('John Doe', 20)  RETURN employee_id, salary INTO v_employee_ids, v_salaries;

3.2.4.10.2. 更新

3.2.4.10.2.1. 支持return/returning子句(一般用于PLSQL中静态SQL)

-- 转换前Oracle SQL:
UPDATE employees  SET salary = v_new_salary  WHERE employee_id = 101  RETURNING salary, eeee INTO @qw, :er;
UPDATE employees SET salary = v_new_salary WHERE employee_id = 101  RETURNING salary, eeee INTO qw, er;
UPDATE employees  SET salary = v_new_salary  WHERE employee_id = 101  RETURN salary, eeee INTO @qw, @er;
UPDATE employees SET salary = v_new_salary WHERE employee_id = 101  RETURN salary, eeee INTO qw, er;

-- 转换后GaussDB-Oracle SQL:
UPDATE employees  SET salary = v_new_salary  WHERE employee_id = 101  RETURNING salary, eeee INTO @qw, :er;
UPDATE employees SET salary = v_new_salary WHERE employee_id = 101  RETURNING salary, eeee INTO qw, er;
UPDATE employees  SET salary = v_new_salary  WHERE employee_id = 101  RETURN salary, eeee INTO @qw, @er;
UPDATE employees SET salary = v_new_salary WHERE employee_id = 101  RETURN salary, eeee INTO qw, er;

3.2.4.10.3. 删除

3.2.4.10.3.1. 支持return/returning子句(一般用于PLSQL中静态SQL)

-- 转换前Oracle SQL:
DELETE FROM employees WHERE salary < 3000  RETURNING employee_id, salary INTO @v_employee_ids, @v_salaries;
DELETE FROM employees WHERE salary < 3000  RETURNING employee_id, salary INTO v_employee_ids, v_salaries;
DELETE FROM employees WHERE salary < 3000  RETURN employee_id, salary INTO @v_employee_ids, @v_salaries;
DELETE FROM employees WHERE salary < 3000  RETURN employee_id, salary INTO v_employee_ids, v_salaries;

-- 转换后GaussDB-Oracle SQL:
DELETE FROM employees WHERE salary < 3000  RETURNING employee_id, salary INTO @v_employee_ids, @v_salaries;
DELETE FROM employees WHERE salary < 3000  RETURNING employee_id, salary INTO v_employee_ids, v_salaries;
DELETE FROM employees WHERE salary < 3000  RETURN employee_id, salary INTO @v_employee_ids, @v_salaries;
DELETE FROM employees WHERE salary < 3000  RETURN employee_id, salary INTO v_employee_ids, v_salaries;