为什么我得到 "PLS-00302: component 'TABLE_NAME' must be declared"?

Why i'm getting "PLS-00302: component 'TABLE_NAME' must be declared"?

我正在尝试在 Oracle 12.2 DB 中创建一个相当简单的存储过程:

create or replace procedure list_tables (
    p_src_schema    varchar2
)
as
    l_src_schema    varchar2(30)    := upper(p_src_schema);
begin
    for x in (select table_name name from all_tables where owner = l_src_schema
              and not regexp_like(table_name, '(AAA|BKP_|LOG_|TMP_|TEST|XX).*')
              order by table_name)
    loop
        dbms_output.put_line(x.table_name);
    end loop;
end;
/
show errors

我收到以下错误:

LINE/COL ERROR
-------- -----------------------------------------------------------------
11/9     PL/SQL: Statement ignored
11/32    PLS-00302: component 'TABLE_NAME' must be declared

错误发生在以下行:dbms_output.put_line(x.table_name);

问题:我做错了什么?我一定是在监督一些非常明显的事情...


更新: 别名 name 已在按下 <TAB> 后由 dBeaver 自动完成“添加”- 我没有注意到它。 ;)

因为您使用了列 别名:

select table_name name from
                  ----

这意味着你应该使用

dbms_output.put_line(x.name);

相反。