Home » SQL & PL/SQL » SQL & PL/SQL » URL Escape using UTL_URL? (10g)
URL Escape using UTL_URL? [message #357236] Tue, 04 November 2008 06:51 Go to next message
plsqlll
Messages: 6
Registered: October 2008
Junior Member
I tried to use:

SELECT utl_url.escape('a url with space.html and a + sign')
FROM dual;

But the escape function doesn't escape + characters even though the documentation states it should.

I want the plus sign to be converted in %2B. Do I need to replace the illegal characters manually?

[Updated on: Tue, 04 November 2008 06:58]

Report message to a moderator

Re: URL Escape using UTL_URL? [message #357241 is a reply to message #357236] Tue, 04 November 2008 07:13 Go to previous messageGo to next message
ThomasG
Messages: 3189
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
According to which documentation?

According to this here, utl_url.escape :

Quote:

Returns a URL with illegal characters (and optionally reserved characters) escaped using the %2-digit-hex-code format



And according to the URL specifications, page 15, a "+" is a "safe" character, not an illegal or reserved one.

Re: URL Escape using UTL_URL? [message #357242 is a reply to message #357241] Tue, 04 November 2008 07:20 Go to previous messageGo to next message
ThomasG
Messages: 3189
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
Sorry, found it here.

So you need to add the escape_reserved_chars boolean parameter, to escape "reserved" characters, too.
Re: URL Escape using UTL_URL? [message #357247 is a reply to message #357236] Tue, 04 November 2008 07:36 Go to previous message
plsqlll
Messages: 6
Registered: October 2008
Junior Member
Ok, thanks! I had seen that documentation before, but I couldn't figure out how to apply the boolean, so I created this:

- Query -

select form_url_encode(DATA, 'ISO-8859-1')
from Dual

- Function -

CREATE OR REPLACE FUNCTION form_url_encode
(
data IN VARCHAR2,
charset IN VARCHAR2) RETURN VARCHAR2 AS
BEGIN
RETURN utl_url.escape(data, TRUE, charset);
END;
Previous Topic: how to get query executed while 1 table and 1 .....
Next Topic: ERROR at line 1: ORA-00947: not enough values
Goto Forum:
  


Current Time: Mon Dec 05 08:45:31 CST 2016

Total time taken to generate the page: 0.05791 seconds