ORA-00942: table or view does not exist (works when a separate sql, but does not work inside a oracle function)
There are a couple of things you could look at. Based on your question, it looks like the function owner is different from the table owner.
1) Grants via a role : In order to create stored procedures and functions on another user's objects, you need direct access to the objects (instead of access through a role).
2)
By default, stored procedures and SQL methods execute with the
privileges of their owner, not their current user.
If you created a table in Schema A and the function in Schema B, you should take a look at Oracle's Invoker/Definer Rights concepts to understand what might be causing the issue.
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/subprograms.htm#LNPLS00809
ORA-00942: table or view does not exist' only when running within a Stored procedure
Sounds like an issue with select privileges granted via a role, rather than directly to the schema. See ORA-00942: table or view does not exist (works when a separate sql, but does not work inside a oracle function).
PL/SQL: ORA-00942: table or view does not exist. Inside Function
The table you're selecting from belongs to user hawk
.
User, which uses the function, should be granted the SELECT
privilege (on that table). I presume that you did that (as SELECT
itself works OK, but not as part of a function) - via some role. However, that won't work - you should grant the privilege directly to user, not via role.
PL/SQL: SQL Statement ignored, PL/SQL: ORA-00942: table or view does not exist
Line 49 refers to ds.md_account_d
. The package belongs to DMA, so probably DS needs to
grant READ on MD_ACCOUNT_D to DMA;
along with any other privileges that are needed.
PL/SQL: ORA-00942: table or view does not exist V$SQL
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
Related Topics
Writing Unicode from R to SQL Server
Count(Id) VS. Count(*) in MySQL
Connecting to Oracle Database Using SQL Server Integration Services
Pivot Dynamically, Returned Results from Join of Two Tables
Pls-00201: Identifier 'User Input' Must Be Declared
SQL Server Table Creation Date Query
How to Trim a String in SQL Server Before 2017
Need a Row Count After Select Statement: What's the Optimal SQL Approach
Group by and Count Using Activerecord
If() Statement Alternative in SQLite
Insert Data and Set Foreign Keys with Postgres
Pivot Without Aggregate Function in Mssql 2008 R2
SQL Set Default Not Working in Ms Access
Why Is Postgresql Not Using My Indexes on a Small Table
How to Add a Column That Doesn't Allow Nulls in a Postgresql Database