1752865 Members
3949 Online
108791 Solutions
New Discussion юеВ

Procedure

 
Prabhu_7
Frequent Advisor

Procedure

I created a procedure (proc1) in SchemaA.

It works fine.

Now i say,
Grant execute on proc1 to SchemaB.

and when try to execute from SchemaB
it wudnt work. it doesnt give any error but
doesnt fetch data from the tables. Tables are local tables , created seperately in both schemas.

Any thoughts!!!!
2 REPLIES 2
Graham Cameron_1
Honored Contributor

Re: Procedure

A few things to check.

1. To execute from schema B you would have to prefix the proc name with the schema name, eg "exec SchemaA.proc1()". Alternatively you could create a synonym pointing eg "create public synonym proc1 for SchemaA.proc1".
If you are not doing either of these then you must be calling a local (ie in schemaB) version of proc1.

2. When SchemaA.proc1 runs, it does so within SchemaA and with the privs of SchemaA. So long as it is accessing tables and other objects in SchemaA this will be ok, but if you want it to access tables in SchemaB you will have to explicitly grant the permissions for SchemaA to see the SchemaB tables. Not only that, if you have tables with the same name in each schema, then SchemaA.proc1 is always going to use its local tables unless you explicitly stipulate SchemaB.TableName.

Hope this helps

-- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
Yogeeraj_1
Honored Contributor

Re: Procedure

hi,

exec schemaname.procname

should work.

Also note that invoker/definer rights also comes into play with procedures/functions and packages.

Where the invoker is the caller of the routine. If I (Yogeeraj) run a stored procedure owned by you that supports invoker rights - I (Yogeeraj) am the invoker and the procedure will run its SQL as if I typed it in -- not you.

If I (Yogeeraj) run a stored procedure owned by you that supports definer rights -- I am still the invoker HOWEVER the procedure will run with YOUR privs -- the DEFINERS privs, not mine.

To add to this -- suppose the definer rights routine YOU wrote calls that invoker rights routine. Now, if I (Yogeeraj) call your definer rights procedure -- it'll execute as you and when it calls the invoker rights routine the invoker this time is YOU -- not me. When we entered that definer rights routine -- that definer becomes the invoker for all other calls (unless it calls another definer rights routine in another schema -- then that schema becomes the invoker)

best regards
and Merry Christmas

Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)