Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't use DBMS_RANDOM functions

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?

like image 639
Əlişiram Avatar asked Jan 27 '26 16:01

Əlişiram


1 Answers

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.

like image 91
APC Avatar answered Jan 29 '26 11:01

APC