使用记录类型对象更新表

Dic*_* Ho 5 oracle plsql

我有一个表说EMPLOYEREMPLOYER_ID作为主键。我编写以下脚本来更新表中的行:

declare
    emp_row EMPLOYER%ROWTYPE;
begin
    select * into emp_row from EMPLOYER where rownum <= 1;
    emp_row.NAME := 'ABC';
    emp_row.AGE  := 99;
    -- Can I write something like below?
    update EMPLOYER set ??? = emp_row where EMPLOYER_ID = emp_row.EMPLOYER_ID;
end;
Run Code Online (Sandbox Code Playgroud)

我可以在单个语句中使用记录类型对象更新行吗?如上例所示。

Sar*_*uri 6

请尝试这样的事情

update EMPLOYER set ROW = emp_row where EMPLOYER_ID = emp_row.EMPLOYER_ID;
Run Code Online (Sandbox Code Playgroud)

请记住:此 UPDATE 设置表中每一列的值,包括您的主键,因此您应该非常小心地使用 SET ROW 语法。