Question of the day:
can DBMS_METADATA.GET_DDL return the DDL for creating a MLE Module?
The short answer is YES even though there is no mention in the official documentation for Oracle version 26ai.
![]() |
| Image courtesy of Google Gemini |
Below the sample script I used to check if the JavaScript module I created using Visual Studio Code could be retrieved using DBMS_METADATA:
-- NOTICE: these settings might need adjustments for other use cases
set feedback off exec DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',true); exec DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM, 'EMIT_SCHEMA', false); set pagesize 0 set linesize 32767 set long 32767 set longchunksize 32767 select dbms_metadata.get_ddl('MLE_MODULE', m.module_name) as obj from user_mle_modules m where m.module_name = 'HTML2MD_MOD';
CREATE OR REPLACE MLE MODULE "HTML2MD_MOD"
LANGUAGE JAVASCRIPT AS
const VOID = new Set(['area','base','br','col','embed','hr','img','input','link','meta','source','track','wbr']);
const SKIP = new Set(['script','style','head','noscript','template','iframe','object','embed','svg','canvas','meta','link']);
const BLOCK = new Set(['p','div','section','article','header','footer','main','nav','aside','figure','figcaption','form','fieldset','dl','dt','dd','address','details','summary','center']);
const ENT = {amp:'&',lt:'<',gt:'>',quot:'"',apos:"'",nbsp:' ',copy:'\u00A9',reg:'\u00AE',trade:'\u2122',hellip:'\u2026',mdash:'\u2014',ndash:'\u2013',lsquo:'\u2018',rsquo:'\u2019',ldquo:'\u201C',rdquo:'\u201D',laquo:'\u00AB',raquo:'\u00BB',bull:'\u2022',middot:'\u00B7',euro:'\u20AC',agrave:'\u00E0',egrave:'\u00E8',eacute:'\u00E9',igrave:'\u00EC',ograve:'\u00F2',ugrave:'\u00F9'};
function decode(s) {
return s.replace(/&(#x[0-9a-f]+|#\d+|[a-z][a-z0-9]*);/gi, (m, e) => {
if (e[0] === '#') {
const cp = (e[1] === 'x' || e[1] === 'X') ? parseInt(e.slice(2), 16) : parseInt(e.slice(1), 10);
try { return String.fromCodePoint(cp); } catch (_) { return m; }
}
const v = ENT[e] !== undefined ? ENT[e] : ENT[e.toLowerCase()];
return v !== undefined ? v : m;
});
}
... etc, etc.
The source of MLE Modules can also be retrieved using views USER_SOURCE / ALL_SOURCE / DBA_SOURCE.
set wrap off
set pagesize 0 set linesize 32767 set long 32767 set longchunksize 32767
column text format A400
select text from user_source where name = 'HTML2MD_MOD' order by line;
const VOID = new Set(['area','base','br','col','embed','hr','img','input','link','meta','source','track','wbr']);
const SKIP = new Set(['script','style','head','noscript','template','iframe','object','embed','svg','canvas','meta','link']);
const BLOCK = new Set(['p','div','section','article','header','footer','main','nav','aside','figure','figcaption','form','fieldset','dl','dt','dd','address','details','summary','center']);
const ENT = {amp:'&',lt:'<',gt:'>',quot:'"',apos:"'",nbsp:' ',copy:'\u00A9',reg:'\u00AE',trade:'\u2122',hellip:'\u2026',mdash:'\u2014',ndash:'\u2013',lsquo:'\u2018',rsquo:'\u2019',ldquo:'\u201C',rdquo:'\u201D',laquo:'\u00AB',raquo:'\u00BB',bull:'\u2022',middot:'\u00B7',euro:'\u20AC',agrave:'\u00E0',egrave:'\u00E8',eacute:'\u00E9',igrave:'\u00EC',ograve:'\u00F2',ugrave:'\u00F9'};
function decode(s) {
return s.replace(/&(#x[0-9a-f]+|#\d+|[a-z][a-z0-9]*);/gi, (m, e) => {
if (e[0] === '#') {
const cp = (e[1] === 'x' || e[1] === 'X') ? parseInt(e.slice(2), 16) : parseInt(e.slice(1), 10);
try { return String.fromCodePoint(cp); } catch (_) { return m; }
}
const v = ENT[e] !== undefined ? ENT[e] : ENT[e.toLowerCase()];
return v !== undefined ? v : m;
});
}
... etc, etc.

No comments:
Post a Comment