1

So I have a function called doLogin, that receives two arguments, and I created a user called user_login. I have granted user_login the following privileges:

GRANT CREATE SESSION TO user_login;
GRANT EXECUTE ON DoLogin TO user_login;
GRANT SELECT ON Utilizadores TO user_login; --do Login gets information from this table

But when connect using user_login and try to run the function, I receive the following error:

Erro: java.sql.SQLException: ORA-06550: line 1, column 13: PLS-00201: identifier 'DOLOGIN' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored

Edit: I would like that only system and user_login have acess to this function

Safirah
  • 365
  • 6
  • 17

1 Answers1

2

Say you defined your function DoLogin in your schema (say yourSchema) and you need to use it from within a different user, say user_login.

You may decide to call the function with

yourSchema.DoLogin

or create a public synonym, from within yourSchema, and then call the function without adding the schema name:

create public synonym DoLogin for DoLogin
Aleksej
  • 22,443
  • 5
  • 33
  • 38
  • Thank you so much for your answer! This indeed solved my problem, but could explain better what are synonyms, I've seen this question: http://stackoverflow.com/questions/2364818/when-should-database-synonyms-be-used but I'm not really understanding – Safirah Jan 02 '17 at 16:18
  • And by the way the synonym created is acessible to all users (if so, that's not what I wanted) – Safirah Jan 02 '17 at 16:22
  • 1
    If you create a public synonym, it will be visible to every user, ma only users with the EXECUTE privilege will be able to run the function. In other words, you can think a public synonym as a way to avoid writing SCHEMA.object, but they give no grant – Aleksej Jan 02 '17 at 16:43
  • Or create a *private* synonym in `user_login` and make it reference `yourSchema.DoLogin`, so you can use it without schema alias from everywhere in `user_login` without exposing it to other users. – GolezTrol Jan 02 '17 at 17:02