Thanks a lot , will try this one Regards
On Tue, Apr 12, 2011 at 1:59 PM, Andreas Kretschmer < akretsch...@spamfence.net> wrote: > akp geek <akpg...@gmail.com> wrote: > > > Hi all - > > > > Is it possible to to split the data of a column into > multiple > > lines. We are have a column which is text. when the query is excecuted, I > > wanted to display the text of the column in separate lines. Is it > possible ? > > Sure, for instace with a function like this: > > test=*# select * from apk ; > t > > ---------------------------------------------------------------------------------------- > this is a long line with text, i will try to split this line to display > multiple lines > (1 Zeile) > > Zeit: 0,251 ms > test=*# create or replace function split_line(t text,count int) returns > text as $$declare i int;c int; ret text; begin ret:= t; i:=0;c:=0;for i > in 0 .. length(ret) loop if substring(ret,i,1) = ' ' then c:=c+1; end > if; if c = count then ret := overlay(ret placing E'\n' from i for 1); > c:= 0; end if; end loop; return ret; end; $$language plpgsql; > CREATE FUNCTION > Zeit: 0,537 ms > test=*# select split_line(t,3) from apk ; > split_line > ------------------------ > this is a > long line with > text, i will > try to split > this line to > display multiple lines > (1 Zeile) > > > > > > Andreas > -- > Really, I'm not out to destroy Microsoft. That will just be a completely > unintentional side effect. (Linus Torvalds) > "If I was god, I would recompile penguin with --enable-fly." (unknown) > Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889° > > -- > Sent via pgsql-general mailing list (pgsql-general@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-general >