Skip to Main Content

Oracle Database Free

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

MLE ist treated as second-class citizen (db_developer_role)

1. Create user DEMO2 (prerequisite)

When you create a new user demo2 in the Oracle Database Free 23c (23.3) like this

create user demo2 identified by demo2
   default tablespace users
   temporary tablespace temp
   quota 1m on users;

grant db_developer_role to demo2;

Then the user demo2 does not have the rights to run JavaScript code.

2. Example using DBMS_MLE (21c-style)

Here's an example using dynamic JavaScript code:

create or replace function hello_world return varchar2 is
   co_js constant clob := q'~
      const bindings = require("mle-js-bindings");
      bindings.exportValue("result", "Hello World");
   ~';
   l_ctx dbms_mle.context_handle_t;
   l_result varchar2(50 char);
begin
   l_ctx := dbms_mle.create_context();
   dbms_mle.eval(l_ctx, 'JAVASCRIPT', co_js);
   dbms_mle.import_from_mle(l_ctx, 'result', l_result);
   dbms_mle.drop_context(l_ctx);
   return l_result;
end;
/

select hello_world;

You can create the function, but the query throws:

ORA-01031: insufficient privileges
ORA-06512: at "SYS.DBMS_MLE", line 418
ORA-06512: at "DEMO2.HELLO_WORLD", line 9

The privilege dynamic mle is missing.

3. Example using JavaScript stored function (23c-Style)

Here's an example using the new JavaStript Stored Procedure functionality introduced in 23c:

create or replace mle module hello_world_mod language javascript as
export function greet() {
   return "Hello World";
}
/

Of course, I would need to define also a call specification in PL/SQL, but I already get the following error:

ORA-04129: insufficient privileges to use MLE language JAVASCRIPT

The privilege javascript is missing, as clearly stated by the error message.

4. Suggested enhancement for the coming 23c versions

Extend the provided role db_developer_role as follows:

grant execute dynamic mle to db_developer_role;
grant execute on javascript to db_developer_role;

IMO if you have the rights to create PL/SQL stored procedures and execute dynamic code in PL/SQL, then I see no reason not to grant users having the db_developer_role the rights to work with JavaScript.

Comments
Post Details
Added on Nov 14 2023
5 comments
534 views