Oracle DB allows writing procedures in the language PL/SQL. These procedures are compiled and stored in database, and are executed within the same server process as the database, thus removing overhead related to transferring query results between processes or over the network.
PostgreSQL also has such a language, called PL/pgSQL. However, PostgreSQL also allows using a user-defined Procedural Language by writing a so-called Procedural Language Handler.
My question is: does Oracle DB allow using a user-defined Procedural Language?
I tried searching the web for "oracle" "Procedural Language Handler"
but saw no relevant results.
Oracle DB allows writing procedures in the language PL/SQL. These procedures are compiled and stored in database, and are executed within the same server process as the database, thus removing overhead related to transferring query results between processes or over the network.
PostgreSQL also has such a language, called PL/pgSQL. However, PostgreSQL also allows using a user-defined Procedural Language by writing a so-called Procedural Language Handler.
My question is: does Oracle DB allow using a user-defined Procedural Language?
I tried searching the web for "oracle" "Procedural Language Handler"
but saw no relevant results.
- Also, SQL Server has CLR user-defined functions written in any .NET language (C#, F#, VB.NET) – phuzi Commented Mar 19 at 13:21
2 Answers
Reset to default 3Oracle databases do not support embedding code written in arbitrary third-party languages into the database.
However, Oracle does allows you to embed Java code into the database using the CREATE JAVA
statement or the loadjava
utility. Then SQL procedures and functions can be written to call the Java code that has been embedded into the database.
More details can be found in the Oracle Database Java Developer's Guide.
- An example of embedding a simple hello world function into the database and then calling it from SQL is given in this answer.
- A more complicated example of using Java to unzip a
BLOB
stored in the database is given in this answer.
And in 21 and above, you have DBMS_MLE (https://docs.oracle/en/database/oracle/oracle-database/21/arpls/dbms_mle.html) supporting Javascript.
Example:
CREATE OR REPLACE FUNCTION json_keys(inputObject JSON) RETURN JSON
AS MLE LANGUAGE JAVASCRIPT
{{
return Object.keys(INPUTOBJECT);
}};
/