Starting with SQL Developer Web version 22.2, you can now work with:
- PL/SQL with embedded JavaScript OR
- JavaScript
This is a Database 21c feature, and it’s part of the Multilingual Engine feature of the Oracle Database. And since we only get paid if we invent new acronyms, that would be ‘MLE.’
The code you are about to see below came from one of our MLE Developer Advocates – Alina Yurenko.
Alina suggested you also check out our colleague Lucas’ resources on MLE. And follow Lucas, too.
MLE is powered by GraalVM, and it can handle way more than Java and JavaScript. But we’re starting the MLE project in the database with JavaScript. I would expect things like Python to follow as the technology matures in future database releases.
I do PL/SQL, why would I care?
There are some really popular and POWERFUL JavaScript libraries out there. Check out this list of popular libraries, and imagine what some of those could be used for in combination with the data in your database. Alina references this potential in her blog post. Go back, click that link, read it.
Now let’s run some code!
I’m logged into a 21c Instance of Oracle, AND I have exec privs on the MLE package (Docs.)
When I have these two requirements satisfied, I see a SQL Worksheet a bit like this –
Look again.
Closer.
In general, to run JavaScript via MLE in your database, you call the MLE package from your PL/SQL code. And that would look like you saw above.
I have a CLOB variable with the JavaScript code in it. And then I do some calls to DBMS_MLE to use it.
But my code above already has that PL/SQL code written, so I can just use the default action.
What if I JUST wanted to run that very specific JavaScript snippet vs my entire PL/SQL program?
Select and Execute
Well, how does that work?
SQL Developer generated the DBMS_MLE bits for you. You can see that if we look at the SQL History for that call.
Just gimme a JavaScript editor, please
Ask and ye shall receive.
Now that we know you’re working with JavaScript, we can use our JavaScript editor toys, parsers, code completers, etc.
As I type my JavaScript, I’ll get helpers –
Ok, it’s exactly what it sounds like.
Let’s try it.
Reminder: I’m your friendly database tools expert.
I’m the kind of JavaScript developer that finds code on the internet, copies and pastes it locally, and changes a few bytes to get what I want.
If you’re looking for help with JavaScript, then we have folks like Alina and Kris. Kris has lots of cool examples of using JavaScript on the CLIENT side to work with your database.