Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

running a store procedure PL/SQL: ORA-01031:

francy77Feb 1 2021

Hi all,
I'm trying to select records from a table, using a store procedure, but I get:
Errore(13,10): PL/SQL: ORA-01031: privilegi insufficienti
at Line 13 there is :
select k_id into id from schema1.t_table_var where k_id=12;

In schema1 i granted
grant insert,update, delete on t_table_var to ico

and if I try to run the query directly (non in a pl/sql procedure) I can get the results; Besides if i try to make a select to another table but in the schema schema1) I can get the result....... I'm getting crazy;

So what I have to do in order to use a table inside a different schema, in a pl/sql procedure?

This post has been answered by Frank Kulash on Feb 1 2021
Jump to Answer

Comments

Frank Kulash
Answer

Hi, @francy77
In schema1 i granted
grant insert,update, delete on t_table_var to ico
Grant the SELECT privilege, as well as INSERT, UPDATE and DELETE.
It sounds like ico has the SELECT privilege only via a role. Roles don't count in AUTHID OWNER stored procedures; all the necessary privileges must be granted directly to the user, or to PUBLIC.
Also, does ico have the CREATE PROCEDURE system privilege?
EDIT: After reading @paulzip 's reply (below) I added AUTHID OWNER above.

Marked as Answer by francy77 · Feb 2 2021
Paulzip

You need the select privilege too,
Also, another thing to bear in mind, is the procedure defined with definer rights (permissions are based on who owns the procedure) or invoker rights (permissions are based on who is calling the procedure)?
The default is definer rights.
Example of invoker rights....

create or replace procedure update_par(pcod in varchar2) authid current_user is 
francy77

I don t know why but granting select was enought, as your suggestion there was a missing SELECT in the grant instruction, so I added it and it works;
The strange thing is that indeed without the select even the delete dos't worked;

1 - 3

Post Details

Added on Feb 1 2021
3 comments
263 views