0% found this document useful (0 votes)
18 views

oracle_javascript

Uploaded by

Huda Khalil
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

oracle_javascript

Uploaded by

Huda Khalil
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Extending

Databases with
code written in
JavaScript
(Oracle vs MySQL
& SQL Server)

Advanced Database
Assignment A
Group: Huda Ibrahim & Denis Muriuki

1
Server-Side Programming
Oracle External Procedures
Oracle Multilingual Engine (MLE) with JavaScript
Oracle (MLE) Advantages & Disadvantages
Creating MLE Module

Index Demo (Oracle MLE module)


ChatGPT Query
MySQL MLE Feature
Demo of MySQL MLE Feature
SQL SERVER External Procedures
Demo of SQL Server using External procedures
2
Oracle Server-Side Programming
• PL/SQL: The primary server-side interface for
Oracle databases, allowing business logic and PL/SQL
data to reside together, improving performance
and efficiency.
Java
• Java & C : Stored procedures could be created
DLLs Language
using any of these languages before Oracle 21c.

• External Procedures: Functions written in third-


generation languages (e.g., C) can be called C Language
within PL/SQL or SQL, functioning like native
routines

3
Oracle External Procedures
1- Write the External Procedure.
External procedures are functions developed in
third-generation languages (e.g., C) that can be
invoked from PL/SQL or SQL, behaving like native 2- Build the DLL using a C compiler and linker.

PL/SQL routines.
3- Register the Procedure in the database.

4- Restrict Library Privileges to trusted users for


security.

5- Execute the Procedure as needed.

4
External Procedures

Advantages Disadvantages
• Performance: Certain tasks execute more • Security Warning: Never set ENVS =
efficiently in third-generation languages "EXTPROC_DLLS = ANY" in listener.ora, as it
compared to PL/SQL, which is optimized for disables DLL verification, allowing attackers to
execute any DLL. This poses a significant security
SQL transaction processing.
risk, even if the Listener is configured for low-
• Code Reusability: Dynamic link libraries privileged users
(DLLs) can be directly invoked from PL/SQL, • C compiler and linker are required to build DLLs.
enhancing modularity and reuse across
server and client tools • Steps of Creating & Registering Dlls.

5
Oracle Multilingual
Engine (MLE) with
JavaScript
•The DBMS_MLE package allows users to
execute JavaScript code inside the Oracle
Database and exchange data seamlessly
between PL/SQL and JavaScript.

•The JavaScript code itself can execute PL/SQL


and SQL through built-in JavaScript modules.

•JavaScript data types are automatically


mapped to Oracle Database data types and vice
versa.

6
Oracle (MLE) Advantages & Disadvantages

Advantages Disadvantages
• The logic gets executed where the data resides. • The strongest privileges in MLE let super-users
create, alter, and drop MLE schema objects in any
• Storing and running business rules in the database
schema, not just their own. Like all privileges in
ensures that all applications and users follow
security and compliance needs. Oracle Database, those with "ANY" in their name
are the most powerful and should only be given to
• Developers can keep application logic and data trusted users if needed
together, which improves data quality

• Server-side JavaScript works closely with the


database, allowing for quick and easy sharing of
data between JavaScript and SQL or PL/SQL

7
Creating MLE Module

Environment Setup

• Grants
• Parameters

Create MLE Module

• Procedures
• Functions

Create a Call Spec

8
Demo (Using MLE
Module and
JavaScript in
Oracle)

Scenario #1

Creating MLE module to


increase employee
salary by 10%

9
ChatGPT Query
PLS-00103: string
Cause: This error message is from the
parser. It found a token (language Question
element) that is inappropriate in this
context.
Action: Check previous tokens as well
as the one given in the error message.
The line and column numbers given in
Answer
the error message refer to the end of
the faulty language construct.

10
MySQL MLE Feature
MySQL introduced the Multilingual Engine
(MLE) feature, it is included in MySQL
Enterprise Edition 9.0, with this feature you
can make and run MySQL programs using
JavaScript language.

You can call other stored programs while


using a JavaScript stored program.

You can also run a JavaScript stored program


from SQL stored programs like stored
procedures, stored functions, events, and
triggers. JavaScript stored programs can also
call themselves again and again.

11
Demo of
MySQL MLE
Feature

Scenario #2

Creating MLE
function to increase
employee salary by
10%

12
SQL SERVER
External Procedures External procedures in SQL Server can be
handled using the common language
runtime which is integrated within the
database itself. One can write and run
stored procedures written in .NET
languages such as C# and VB.NET.

This is better than using Transact-SQL


which cannot run on a client’s computer
since it is processor intensive and placing it
on your database server will be
detrimental. Common language runtime
(CLR) allows one to write extended stored
procedures that implement the richness
of .NET libraries and its languages

13
Demo of SQL Server using External Procedures
• Creating External
procedure on
Microsoft
SQLServer and
Visual Studio 2022
using C# and SQL.

• The SQL query


should return the
current date with
no errors.

14
Thank you
15

You might also like