【问题标题】:Can we use %rowtype attribute inside the plsql record?我们可以在 plsql 记录中使用 %rowtype 属性吗?
【发布时间】:2022-07-01 02:32:47
【问题描述】:

我们可以像下面的代码那样在plsql记录中使用%rowtype属性吗..

类型 xx 是 RECORD ( v_emp 员工%rowtype , v_loc 部门.LOCATION_ID%type ); v_data xx;

【问题讨论】:

  • 当你尝试执行这段代码时编译器会告诉你什么?

标签: sql oracle plsql oracle11g plsqldeveloper


【解决方案1】:

我可以,我希望你也可以。

SQL> set serveroutput on
SQL>
SQL> declare
  2    type xx is RECORD
  3      ( v_emp emp%rowtype ,
  4        v_loc dept.LOC%type );
  5    v_data xx;
  6  begin
  7    v_data.v_emp.ename := 'LF';
  8    v_data.v_loc := 'x';
  9
 10    dbms_output.put_line(v_data.v_emp.ename ||', '|| v_data.v_loc);
 11  end;
 12  /
LF, x

PL/SQL procedure successfully completed.

SQL>

【讨论】: