From: | akp geek <akpgeek(at)gmail(dot)com> |
---|---|
To: | Andreas Kretschmer <akretschmer(at)spamfence(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: word wrap in postgres |
Date: | 2011-04-12 18:12:38 |
Message-ID: | BANLkTikuQByP1Urc_iGqU9n9TTYKpZt4Xw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thanks a lot , will try this one
Regards
On Tue, Apr 12, 2011 at 1:59 PM, Andreas Kretschmer <
akretschmer(at)spamfence(dot)net> wrote:
> akp geek <akpgeek(at)gmail(dot)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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
From | Date | Subject | |
---|---|---|---|
Next Message | Henry C. | 2011-04-12 19:45:12 | Trying out replication: cp cannot stat log file during recovery |
Previous Message | Andreas Kretschmer | 2011-04-12 17:59:27 | Re: word wrap in postgres |