UTL URL

From Oracle FAQ
Jump to: navigation, search

UTL_URL is an PL/SQL package that can escape and unescape URL's.

[edit] ESCAPE

Escape example - the space will be escaped as %20:

SQL> SELECT utl_url.escape('http://www.orafaq.com/wiki/SQL FAQ') FROM dual;
 UTL_URL.ESCAPE('HTTP://WWW.ORAFAQ.COM/WIKI/SQLFAQ')
 ---------------------------------------------------
 http://www.orafaq.com/wiki/SQL%20FAQ

[edit] UNESCAPE

Unescape example - %20 will be un-escaped as a space:

SQL> SELECT utl_url.unescape('http://www.orafaq.com/wiki/SQL%20FAQ') FROM dual;
 UTL_URL.UNESCAPE('HTTP://WWW.ORAFAQ.COM/WIKI/SQL%20FAQ')
 --------------------------------------------------------
 http://www.orafaq.com/wiki/SQL FAQ

To decode additional \x?? hex values, you can:

SELECT utl_url.unescape(translate('http://myurl.com/\x20ho\xfc', '\x', '%')) FROM dual;