Re: [SQL] Using CASE in plpgsql causes 'ERROR: cache lookup failed'

2010-04-14 Thread Tom Lane
Mario Splivalo writes: > When I call 'service_something' function and provide nonexistent > service_id I get this error: > ERROR: cache lookup failed for type 37 Hmm. Looks like exec_eval_expr should be more careful about setting a result datatype when the expression returns no rows. NULL is

Re: [SQL] graphing time series data

2010-04-14 Thread Pavel Stehule
2010/4/14 Louis-David Mitterrand : > On Wed, Apr 14, 2010 at 06:06:59PM +0200, Pavel Stehule wrote: >> I don't understand well. Why you don't use a function date_trunc(), >> >> select date_trunc('week', created), count(*) >> from price >> group by date_trunc('week', created) > > Because if a price

Re: [SQL] graphing time series data

2010-04-14 Thread Louis-David Mitterrand
On Wed, Apr 14, 2010 at 06:06:59PM +0200, Pavel Stehule wrote: > I don't understand well. Why you don't use a function date_trunc(), > > select date_trunc('week', created), count(*) > from price > group by date_trunc('week', created) Because if a price doesn't change for more than a week, then so

Re: [SQL] graphing time series data

2010-04-14 Thread Pavel Stehule
2010/4/14 Louis-David Mitterrand : > On Wed, Apr 14, 2010 at 08:46:13AM -0700, Richard Broersma wrote: >> On Wed, Apr 14, 2010 at 7:54 AM, Louis-David Mitterrand >> wrote: >> >> > Now, I'd like to make a graph of average prices per week, per >> > id_product. As some prices don't vary much, distrib

Re: [SQL] graphing time series data

2010-04-14 Thread Louis-David Mitterrand
On Wed, Apr 14, 2010 at 08:46:13AM -0700, Richard Broersma wrote: > On Wed, Apr 14, 2010 at 7:54 AM, Louis-David Mitterrand > wrote: > > > Now, I'd like to make a graph of average prices per week, per > > id_product. As some prices don't vary much, distribution would not be > > ideal if I simply

Re: [SQL] graphing time series data

2010-04-14 Thread Richard Broersma
On Wed, Apr 14, 2010 at 7:54 AM, Louis-David Mitterrand wrote: > Now, I'd like to make a graph of average prices per week, per > id_product. As some prices don't vary much, distribution would not be > ideal if I simply 'group by extract(week from p.modified)'. I created a view for a similar prob

[SQL] graphing time series data

2010-04-14 Thread Louis-David Mitterrand
Hi, I have times series data in a 'price' table: price(id_price, price, id_product, created, modified) Prices are polled daily and a new 'price' row is created only if the price of id_product changes, else modified is updated to now(). Now, I'd like to make a graph of average prices per week, p

[SQL] Using CASE in plpgsql causes 'ERROR: cache lookup failed'

2010-04-14 Thread Mario Splivalo
I have an enum-type, like this: CREATE TYPE type_enum_service_type AS ENUM ('Banner', 'Ticker', 'Memo'); Then I have a table, like this: CREATE TABLE services ( service_id integer NOT NULL, service_type type_enum_service_type NOT NULL, service_keyword character varying NOT NULL, servi