PL/SQL: ORA-00942: table or view does not exist V$SQL

前端 未结 3 1711
暗喜
暗喜 2021-02-14 23:34

I have created a procedure and used the below statement inside that .

select sql_id into v_sql_id from v_$sql where sql_text =v_sql;

I am getti

相关标签:
3条回答
  • 2021-02-15 00:05

    Database dictionary related or system tables (v_$sql in this case) are owned by Oracle sys user and needs special privileges to access them. You need to login to oracle database as sysdba user or get those privilages (your DBA might help you with this) to get access for the data dictionary views.

    As mentioned in this article

    The problem is that procedures don't respect roles; only directly granted rights 
    are respected. So, that means that table_owner has to regrant the right to select
    

    So, try the following to grant the SELECT on all dictionay view so that you can use it in your pl/sql blocks.

    grant select any dictionary to USERNAME
    
    0 讨论(0)
  • 2021-02-15 00:17

    Most probably the user you are using was given access to the view through a role rather than the select privilege directly.

    Unfortunately privileges obtained through a role are not active when running PL/SQL.

    You need to ask your DBA to grant the SELECT privilege directly to your user.

    0 讨论(0)
  • 2021-02-15 00:28

    See my answer here. It might be because you are using specific capitalisation somewhere

    0 讨论(0)
提交回复
热议问题