1

I am getting this error when I am trying to use the table in a Stored Procedure. When I do a select * from table, i get results. But when I put it in the Stored Procedure (join with other table) and compile, I get the error, Error(269,17): PL/SQL: ORA-00942: table or view does not exist

Any idea on why this is happening?

2
  • only select from that table works in stored procedure ?
    – Frank
    Aug 31, 2017 at 12:58
  • 2
    Perhaps you only have access to the table via a grant to a role. You need a direct grant to your schema to use the table in a procedure. Aug 31, 2017 at 13:01

2 Answers 2

4

To use a table from one schema in a stored procedure owned by another schema, the procedure's schema needs a direct grant on the table:

grant select on ALPS.CUST_LOOKUP_DTL to myschema;

A grant to a role that the schema has is not enough:

grant select on ALPS.CUST_LOOKUP_DTL to some_role;
grant some_role to myschema;

In this case myschema can select from the table, but its procedures cannot.

1
  • The general concept is correct. However, Oracle procedures can be defined either with definer's rights (the default) or invoker's rights. The procedure's owner (schema) is relevant only for definer's rights procedures. If the procedure's owner has all the required rights and the procedure will still not work, that is often a sign that the procedure was written with invoker's rights (the user who invokes the procedure).
    – user5683823
    Aug 31, 2017 at 14:45
1

What happens when you execute what you have in your stored procedure? You mention a join table - that not the same as select * from table. You may have to fully qualify the table name by schema name.

select * from schema.table;

1
  • I use: select * from ALPS.CUST_LOOKUP_DTL and in join also i do, INNER JOIN ALPS.CUST_LOOKUP_DTL
    – Minu
    Aug 31, 2017 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.