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