Search Postgresql Archives

Re: Error after upgrade

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Paul Houselander" <housey@xxxxxxxxxxxxxx> 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

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux