Empezando con JavaScript en Oracle: Casos de uso y procedimientos simples de MLE

Descubre cómo empezar a utilizar JavaScript en Oracle con diferentes casos de uso y procedimientos simples de MLE.

18 nov 2025 • 3 min read • Q2BSTUDIO Team

Getting Started with JavaScript in Oracle: Use Cases and Simple MLE Procedures

Oracle Multilingual Engine MLE permite ejecutar JavaScript directamente dentro de la base de datos junto a PL/SQL, lo que facilita crear procedimientos, funciones y módulos en JavaScript que pueden ser invocados desde PL/SQL. Esta integración es ideal para quienes comienzan porque permite mezclar SQL y JavaScript de forma rápida, probar pequeñas piezas de lógica y reutilizar código en un lenguaje conocido.

Procedimiento inline JavaScript anónimo Uso práctico para pruebas rápidas: permite ejecutar lógica JavaScript sin crear un módulo. Ejemplo conceptual: CREATE OR REPLACE PROCEDURE inline_js_demo AS MLE LANGUAGE JAVASCRIPT PURE { let msg = Hello from inline JavaScript!; console.log(msg); }; Ejecución: BEGIN inline_js_demo; END; Resultado: ejecución rápida de lógica JS sin crear un módulo, útil para cálculos pequeños o pruebas.

Suma de dos números con PURE Expone el entorno PURE y lógica aritmética sencilla. Módulo conceptual: CREATE OR REPLACE MLE MODULE calc_mod LANGUAGE JAVASCRIPT AS export function sum(a, b) { return a + b; } Entorno PURE: CREATE OR REPLACE MLE ENV calc_env IMPORTS (calc_mod MODULE calc_mod) PURE; Procedimiento y firma: CREATE OR REPLACE FUNCTION js_add(p_a NUMBER, p_b NUMBER) RETURN NUMBER AS MLE MODULE calc_mod ENV calc_env SIGNATURE sum(num,num); Llamada de ejemplo: SELECT js_add(10, 25) AS result FROM dual;

Convertir texto a mayúsculas con JS Muestra funciones de cadena y retorno de valores. Función inline: CREATE OR REPLACE FUNCTION js_upper(p_text VARCHAR2) RETURN VARCHAR2 AS MLE LANGUAGE JAVASCRIPT { let input = session.getInput(TEXT); return input.toUpperCase(); }; Llamada: SELECT js_upper(hello oracle js mle) FROM dual;

Calcular salario promedio desde una tabla usando el driver SQL de MLE Enseña a ejecutar SQL dentro de JavaScript usando el driver mle js oracledb. Módulo conceptual: CREATE OR REPLACE MLE MODULE emp_mod LANGUAGE JAVASCRIPT AS import * as oracledb from mle-js-oracledb; export function avgSalary() { let conn = oracledb.defaultConnection(); let rs = conn.query( SELECT AVG(salary) avg_sal FROM Employees ); return rs[0].AVG_SAL; } Firma y uso: CREATE OR REPLACE FUNCTION js_emp_avg RETURN NUMBER AS MLE MODULE emp_mod SIGNATURE avgSalary(); Llamada: SELECT js_emp_avg FROM dual;

Consejos prácticos y buenas prácticas Emplea entornos PURE para funciones deterministas y sin efectos secundarios. Usa módulos para encapsular lógica reutilizable y facilita pruebas unitarias desde PL/SQL. Aprovecha las capacidades del driver SQL de MLE para combinar consultas complejas con procesamiento en JavaScript cuando sea conveniente.

Sobre Q2BSTUDIO Somos Q2BSTUDIO, empresa de desarrollo de software y aplicaciones a medida especializada en crear soluciones adaptadas a cada cliente. Ofrecemos servicios integrales que incluyen desarrollo de software a medida, inteligencia artificial, ciberseguridad, servicios cloud aws y azure, servicios inteligencia de negocio, ia para empresas, agentes IA y Power BI. Si necesita una solución personalizada consulte nuestras opciones de aplicaciones a medida en desarrollo de aplicaciones y software multiplataforma y descubra nuestras propuestas en inteligencia artificial en servicios de inteligencia artificial. Trabajamos también en seguridad y pentesting para proteger sus activos digitales.

Palabras clave y posicionamiento Este artículo incluye términos relevantes para búsqueda y posicionamiento como aplicaciones a medida, software a medida, inteligencia artificial, ciberseguridad, servicios cloud aws y azure, servicios inteligencia de negocio, ia para empresas, agentes IA y power bi. Para proyectos que integren bases de datos Oracle con lógica JavaScript, o para migraciones y modernizaciones, Q2BSTUDIO aporta experiencia técnica y propuestas a medida para su negocio.

Si desea una consultoría o un proyecto a medida podemos ayudarle a evaluar cuándo usar MLE para simplificar integraciones entre PL/SQL y JavaScript, optimizar rendimiento y mantener buenas prácticas de seguridad y gobernanza en la nube.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.