UNICODE and PL/PGSQL

Поиск
Список
Период
Сортировка
От Bart Degryse
Тема UNICODE and PL/PGSQL
Дата
Msg-id 456AD17A020000300000FB60@webaccess.indicator.be
обсуждение исходный текст
Ответы Re: UNICODE and PL/PGSQL
Список pgsql-sql
Dear all,
This works: SELECT '\x65'; => it returns the letter 'e'.
When I do the following in PL/PGSQL it returns the same letter 'e' (as might be expected);
 
CREATE OR REPLACE FUNCTION "public"."myfunction" (out result varchar) RETURNS varchar AS
$body$
DECLARE
  charset varchar := '';
BEGIN
  charset := charset || '\x65';
  result := charset;
  RETURN;
END;
$body$
LANGUAGE 'plpgsql' IMMUTABLE RETURNS NULL ON NULL INPUT SECURITY INVOKER;
 
However, when I compose charset dynamically it doesn't work anymore. Following function returns 'x65' instead of 'e'.
Can anyone tell me why that is and how to make it work? The target is of course to change the values in the FOR control structure.
 
CREATE OR REPLACE FUNCTION "public"."myfunction" (out result varchar) RETURNS varchar AS
$body$
DECLARE
  charset varchar := '';
BEGIN
  FOR i IN 101..101 LOOP
    charset := charset || '\x' || to_hex(i);
  END LOOP;
  result := charset;
  RETURN;
END;
$body$
LANGUAGE 'plpgsql' IMMUTABLE RETURNS NULL ON NULL INPUT SECURITY INVOKER;
 
Thanks for any help.
Bart
 

В списке pgsql-sql по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: select into
Следующее
От: Markus Schaber
Дата:
Сообщение: Re: PgAgent [where is it?]