Re: [GENERAL] Crosstab Problems

2007-10-25 Thread Scott Marlowe
On 10/24/07, Tom Lane [EMAIL PROTECTED] wrote: Joe Conway [EMAIL PROTECTED] writes: Tom Lane wrote: 1. Treat NULL rowid as a category in its own right. This would conform with the behavior of GROUP BY and DISTINCT, for instance. In any case, the attached changes the behavior to #1 for

Re: [GENERAL] Crosstab Problems

2007-10-25 Thread Reg Me Please
Il Thursday 25 October 2007 16:29:33 Scott Marlowe ha scritto: On 10/24/07, Tom Lane [EMAIL PROTECTED] wrote: Joe Conway [EMAIL PROTECTED] writes: Tom Lane wrote: 1. Treat NULL rowid as a category in its own right. This would conform with the behavior of GROUP BY and DISTINCT, for

Re: [GENERAL] Crosstab Problems

2007-10-24 Thread Joe Conway
Tom Lane wrote: Jorge Godoy [EMAIL PROTECTED] writes: Em Thursday 18 October 2007 16:37:59 Joe Conway escreveu: The row is pretty useless without a rowid in this context -- it seems like the best thing to do would be to skip those rows entirely. Of course you could argue I suppose that it

Re: [GENERAL] Crosstab Problems

2007-10-24 Thread Tom Lane
Joe Conway [EMAIL PROTECTED] writes: Tom Lane wrote: 1. Treat NULL rowid as a category in its own right. This would conform with the behavior of GROUP BY and DISTINCT, for instance. In any case, the attached changes the behavior to #1 for both flavors of crosstab (the original

Re: [GENERAL] Crosstab Problems

2007-10-19 Thread Stefan Schwarzer
But when re-doing the query now without the JOIN, it works (almost): SELECT * FROM crosstab( 'SELECT id_country AS id, year_start AS year, value FROM agri_area AS d WHERE year_start = 2003 OR year_start =

Re: [GENERAL] Crosstab Problems

2007-10-19 Thread Gregory Stark
Tom Lane [EMAIL PROTECTED] writes: 3. Throw a NOTICE or WARNING (hopefully only one message not repeated ones) if NULL rowid is seen, then ignore the row. From my experience with OLTP I don't like this one. A warning for DML is effectively the same as an error if you're running thousands of

[GENERAL] Crosstab Problems

2007-10-18 Thread Stefan Schwarzer
Hi there, successfully installed the tablefunc package. Now, I would like to transform this kind of result based on a normal SQL: c_name |year|value --- Germany | 2001| 123 Germany | 2002| 125 Germany

Re: [GENERAL] Crosstab Problems

2007-10-18 Thread Tom Lane
Stefan Schwarzer [EMAIL PROTECTED] writes: I had a couple of problems getting there. But now that I have the feeling that this is OK, it tells me this: server closed the connection unexpectedly Could you provide a self-contained test case for this? There's not really enough information

Re: [GENERAL] Crosstab Problems

2007-10-18 Thread Stefan Schwarzer
Could you provide a self-contained test case for this? There's not really enough information here for someone else to duplicate the problem. Also, which PG version are you using? Wasn't sure what you ment with a self containted test case. Is it the raw data? Here is a SQL dump for the

Re: [GENERAL] Crosstab Problems

2007-10-18 Thread Tom Lane
Stefan Schwarzer [EMAIL PROTECTED] writes: Here is a SQL dump for the table. One can just neglect the JOIN with the countries table (which just replaces the country id with the country name): http://geodata.grid.unep.ch/download/sql_agri_area.sql.zip But when re-doing the query now

Re: [GENERAL] Crosstab Problems

2007-10-18 Thread Scott Marlowe
On 10/18/07, Stefan Schwarzer [EMAIL PROTECTED] wrote: Could you provide a self-contained test case for this? There's not really enough information here for someone else to duplicate the problem. Also, which PG version are you using? Wasn't sure what you ment with a self containted test

Re: [GENERAL] Crosstab Problems

2007-10-18 Thread Scott Marlowe
On 10/18/07, Stefan Schwarzer [EMAIL PROTECTED] wrote: But when re-doing the query now without the JOIN, it works (almost): SELECT * FROM crosstab( 'SELECT id_country AS id, year_start AS year, value FROM agri_area

Re: [GENERAL] Crosstab Problems

2007-10-18 Thread Joe Conway
Tom Lane wrote: so it's trying to pstrdup a null result from SPI_getvalue. Obviously it shouldn't crash, but I'm not sure what it *should* do in this case. Joe? The row is pretty useless without a rowid in this context -- it seems like the best thing to do would be to skip those rows

Re: [GENERAL] Crosstab Problems

2007-10-18 Thread Jorge Godoy
Em Thursday 18 October 2007 16:37:59 Joe Conway escreveu: Tom Lane wrote: so it's trying to pstrdup a null result from SPI_getvalue. Obviously it shouldn't crash, but I'm not sure what it *should* do in this case. Joe? The row is pretty useless without a rowid in this context -- it

Re: [GENERAL] Crosstab Problems

2007-10-18 Thread Tom Lane
Jorge Godoy [EMAIL PROTECTED] writes: Em Thursday 18 October 2007 16:37:59 Joe Conway escreveu: The row is pretty useless without a rowid in this context -- it seems like the best thing to do would be to skip those rows entirely. Of course you could argue I suppose that it ought to throw an

Re: [GENERAL] Crosstab Problems

2007-10-18 Thread Joe Conway
Tom Lane wrote: Jorge Godoy [EMAIL PROTECTED] writes: Em Thursday 18 October 2007 16:37:59 Joe Conway escreveu: The row is pretty useless without a rowid in this context -- it seems like the best thing to do would be to skip those rows entirely. Of course you could argue I suppose that it