Re: Error after upgrade - Mailing list pgsql-general

From Tom Lane
Subject Re: Error after upgrade
Date
Msg-id 4178.1201542063@sss.pgh.pa.us
Whole thread Raw
In response to Error after upgrade  ("Paul Houselander" <housey@sme-ecom.co.uk>)
List pgsql-general
"Paul Houselander" <housey@sme-ecom.co.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

pgsql-general by date:

Previous
From: "Dominique Bessette - Halsema"
Date:
Subject: Re: close connection
Next
From: "Douglas McNaught"
Date:
Subject: Re: close connection