3

I use Oracle Database 11g and I have a fairly simple code:

set serveroutput on format wrapped;
declare
result_ clob;
begin
result_ := dbms_random.string('P', 10);
dbms_output.put_line(result_);
end;

When I try to run it gives me an error saying:

identifier 'DBMS_RANDOM' must be declared

Why dbms_random is not recognized as a valid identifier? Do I have to import it?

4
  • 3
    it is dbms_random, not dmbs_random. And you should get a grant from a DBA if you do not have rights to use it. Commented Oct 1, 2018 at 7:19
  • 1
    As @FlorinGhita said. If you have the sys password, this is how to grant (execute as sys): GRANT EXECUTE ON SYS.DBMS_RANDOM TO <your user name here>; Commented Oct 1, 2018 at 7:21
  • @FlorinGhita sorry, it was a typo. I edited the question. But the problem still persists. Commented Oct 1, 2018 at 7:22
  • @FlorinGhita Thanks for quick help. It was a privilege issue as you mentioned. Commented Oct 1, 2018 at 7:31

1 Answer 1

8

Probably this is a permissions problem. EXECUTE on DBMS_RANDOM is not granted by default, so you need a DBA user to grant you the EXECUTE privilege.

grant execute on dbms_random to << your_username >>;

There is an outside chance the package is not installed, although installation is the default. Again, you need a DBA user to check, and if need be run the installation script.

Sign up to request clarification or add additional context in comments.

1 Comment

I didn't have a permission to use dbms_random. I could run the code successfully once I gained permission.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.