pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bart Degryse <Bart.Degryse@indicator.be>
To: pgsql-sql@postgresql.org
Subject: UNICODE and PL/PGSQL
Date: Mon, 27 Nov 2006 11:52:26 +0100
Message-ID: <456AD17A020000300000FB60@webaccess.indicator.be> (raw)

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
 

view thread (16+ messages)  latest in thread

Message-ID: <456AD17A020000300000FB60@webaccess.indicator.be>
Permalink:  ../456AD17A020000300000FB60@webaccess.indicator.be/
Also on:    postgresql.org/message-id/456AD17A020000300000FB60@webaccess.indicator.be

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: Bart.Degryse@indicator.be
  Subject: Re: UNICODE and PL/PGSQL
  In-Reply-To: <456AD17A020000300000FB60@webaccess.indicator.be>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox