From: | Jasen Betts <jasen(at)xnet(dot)co(dot)nz> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Appending a newline to a column value - in a psql cronjob |
Date: | 2012-01-18 10:46:50 |
Message-ID: | jf67uq$g4m$2@reversiblemaps.ath.cx |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 2012-01-13, Alexander Farber <alexander(dot)farber(at)gmail(dot)com> wrote:
> Hello!
>
> I'm using PostgreSQL 8.4.9 on CentOS 6.2 and with bash.
>
> The following cronjob works well for me
> (trying to send a mail to myself - for moderation):
>
> 6 6 * * * psql -c "select
> 'http://mysite/user.php?id=' ||id, about from pref_rep where
> length(about) > 1 and last_rated > now() - interval '1 day'"
>
> but I can't figure out how to append a newline to the
> 1st value (because otherwise the line is too long
> and I have to scroll right in my mail reader):
[several command-line attempts skipped]
I'd be incluned to cheat and use a literal newline like this:
psql -c "select 'http://mysite/user.php?id=' ||id|| '
' ..... ";
I think the one you're groping in the dark for is this:
psql -c "select 'http://mysite/user.php?id=' ||id|| e'\\n' ..... ";
but I think the real problem is that that road doesn't lead where you
want to go as after appending the neline psql reformats the content
into columns (this is usually a good thing).
As you;re using cron and not the command line the rules about what's
allowable change.
try this:
psql -c "select http://mysite/user.php?id=' ||id || e'\n' || about from pref_rep where
length(about) > 1 and last_rated > now() - interval '1 day'"
or possibly with more backslashes: I'm not sure what cron does to backslashes (if anything)
--
⚂⚃ 100% natural
From | Date | Subject | |
---|---|---|---|
Next Message | Gnanakumar | 2012-01-18 11:04:28 | On duplicate ignore |
Previous Message | pasman pasmański | 2012-01-18 07:36:22 | Re: Pgsql problem |