Re: Error after upgrade

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Paul Houselander" <housey(at)sme-ecom(dot)co(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Error after upgrade
Date: 2008-01-28 17:41:03
Message-ID: 4178.1201542063@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Paul Houselander" <housey(at)sme-ecom(dot)co(dot)uk> writes:
> $uweeklysqlu = "UPDATE stats_? SET
> statdate=?,inctr=inctr+?,insize=insize+?,inspam=inspam+?,invir=invir+?,outct
> r=outctr+?,outsize=outsize+?,outspam=outspam+?,outvir=outvir+? WHERE
> account=? AND stattype=? AND statmode=? AND extract(week from
> statdate)=extract(week from date ?) and extract(year from
> statdate)=extract(year from date ?)";

"date ?" is incorrect. You got away with it before because you were
using an older driver that substituted a literal constant into the query
before sending it (ie, the query wasn't really prepared at all). The
right way is "?::date", or more verbosely "CAST(? AS date)". See the
discussions of casting and assigning types to constants in sections
4.1.2.5 and 4.2.8 of the manual.

I doubt that "stats_?" as a table name is going to work either.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2008-01-28 18:56:30 Re: [GENERAL] SHA1 on postgres 8.3
Previous Message Dominique Bessette - Halsema 2008-01-28 17:31:52 Re: close connection