Returning a long string (varchar from a function) - Mailing list pgsql-novice

From Oisin Glynn
Subject Returning a long string (varchar from a function)
Date
Msg-id 00a601c50ecd$1d702320$a974fea9@homisco.local
Whole thread Raw
In response to Re: Finding column using SQL query.  ("Rajan Bhide" <rbhide@starentnetworks.com>)
Responses Re: Returning a long string (varchar from a function)
List pgsql-novice
I have a function that I am using to provide results back to a program.

I want/need to pass a long  string approx. 400chars back from this.

I am getting cut off at 256...

Any way around this.  I would be greatful for any help.  Below is a dummy
function showing the error.It should return a long list of 'aaaaaa'with the
number of a's appended to the end.

select * from zfunc_test(7);
'aaaaaaa7'


select * from zfunc_test(254);
Gets chopped off to '...aaaa25'



-- Function: zfunc_test(int4)

-- DROP FUNCTION zfunc_test(int4);

CREATE OR REPLACE FUNCTION zfunc_test(int4)
  RETURNS "varchar" AS
$BODY$DECLARE

v_length integer;
v_retval varchar;
v_counter integer;

BEGIN
v_length = $1;
v_counter =0;
v_retval :='';
WHILE v_counter < v_length LOOP
    v_retval := v_retval || 'a';
    v_counter:=v_counter +1;
END LOOP;
v_retval  :=v_retval || CAST(v_length as VARCHAR);
return v_retval;
END;


$BODY$
  LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION zfunc_test(int4) OWNER TO postgres;



pgsql-novice by date:

Previous
From:
Date:
Subject: Re: Last ID Problem
Next
From: Michael Fuhr
Date:
Subject: Re: Last ID Problem