Re: URL Decode function

Поиск
Список
Период
Сортировка
Искать
От
MichaelDBA
Тема
Re: URL Decode function
Дата
Msg-id
ed9bfcd4-f052-5ccd-5304-b70f8643a171@sqlexec.com
Ответ на
URL Decode function (JORGE MALDONADO)
Список
Дерево обсуждения
URL Decode function JORGE MALDONADO <jorgemal1960@gmail.com>
Re: URL Decode function MichaelDBA <MichaelDBA@sqlexec.com>
Re: URL Decode function Andreas Joseph Krogh <andreas@visena.com>
Re: URL Decode function MichaelDBA <MichaelDBA@sqlexec.com>
Hi,

You can create your own "decode" function in pg like this example using varchars as input.  Then simply create other overloaded "decode" functions for different input datatypes.

CREATE OR REPLACE FUNCTION decode(expr varchar, search varchar, result varchar, dflt varchar) RETURNS varchar AS
$$      
BEGIN
CASE WHEN expr = search THEN RETURN result; ELSE RETURN dflt; END CASE;
END
$$ LANGUAGE plpgsql;

Regards,
Michael Vitale

JORGE MALDONADO wrote on 4/6/2021 12:34 AM:
Hi,

In my DB, one of my tables has a field that is URL Encoded (its value is a URL of course).

For example, the value:
is URL Encoded like this:
https%3A%2F%2Fwww.cosmohits.com%2FListasPopularidad%2FListaPopularidad%2F1-la-superlista

Is there a PostgreSQL function to URL Decode such field when performing a SELECT statement? I have not found anything in documentation.

Best regards,
Jorge Maldonado

Virus-free. www.avast.com

В списке pgsql-sql по дате отправления
От: JORGE MALDONADO
Дата:
Сообщение: URL Decode function
От: Andreas Joseph Krogh
Дата:
Сообщение: Re: URL Decode function
FAQ