Search code examples
oracle-databasefunctionpublicsynonym

What to do to define PUBLIC Oracle function callable from any schemas WITHOUT specifying schema's name?


I have writen a new Oracle function named TO_X_NUMBER on a common schema named COMMOX.

Every time I will use this function from another schema, I must prefix the function's name by schema's name like this

select COMMOX.TO_X_NUMBER('123,98') from DUAL;

What can I do to use this function without specifying the schema's name like in following SQL command ?

select TO_X_NUMBER('123,98') from DUAL;

Solution

  • First Solution: create a synomym for TO_X_NUMBER function like this

    create PUBLIC synonym TO_X_NUMBER for COMMOX.TO_X_NUMBER;
    
    grant execute on TO_X_NUMBER to PUBLIC;