From: | Reece Hart <reece(at)harts(dot)net> |
---|---|
To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | text formatting in a query, a la sprintf |
Date: | 2006-08-19 20:59:17 |
Message-ID: | 1156021157.4158.496.camel@tallac.gene.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I often desire text and number formatting that's not available with
functions like to_char. I'd really like to have functionality akin to
sprintf, such as:
$ select no_hits,term,sprintf('http://google.com?q=%
s',replace(queryterm,' ','+')) as url from queries;
$ select event,sprintf("%.2g",probability) as prob from event_probs;
$ select sprintf('<td color="%s">%s</td>',color,content) as td_cell from
cells;
I considered a plperl function to do this, but plperl can't take
anyarray and that means that I'd have to resort to ugliness like coding
for specific numbers of args or encoding args them within in a single
string... ick!
Is there a way to get more flexible formatting as in these examples
within a backend query, even if not with sprintf per se?
Thanks,
Reece
--
Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0
From | Date | Subject | |
---|---|---|---|
Next Message | John Gunther | 2006-08-19 22:28:35 | Locale, encoding, sort order confusion |
Previous Message | Andrew Sullivan | 2006-08-19 17:46:57 | Re: problem with postgres SQL db |