0

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.

1
  • Also, SQL Server has CLR user-defined functions written in any .NET language (C#, F#, VB.NET) Commented Mar 19 at 13:21

2 Answers 2

3

Oracle 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.
Sign up to request clarification or add additional context in comments.

Comments

2

And in 21 and above, you have DBMS_MLE (https://docs.oracle.com/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);
}};
/

Comments

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.