Thread: problem with view

problem with view

From
Oleg Bartunov
Date:
Hi,

reading  "The practical SQL handbook" by Bowman et.al (third edition)
I tried to do some examples (there is CD comes with book)  and after
porting example bookbiz database to 6.4.2 I found a problem with view:

create view categories
as select type as Category, avg(price) as Average_Price
from titles
group by Category;



bookbiz=> \d categories

Table    = categories
+----------------------------------+----------------------------------+-------+
|              Field               |              Type                | Length|
+----------------------------------+----------------------------------+-------+
| category                         | char()                           |    12 |
| average_price                    | money                            |     4 |
+----------------------------------+----------------------------------+-------+

bookbiz=> select * from categories;
category    |average_price
------------+-------------
business    |$13.73
mod_cook    |$2.99
popular_comp|$22.95
psychology  |$13.50
trad_cook   |$16.45           |
(6 rows)

bookbiz=> select category,average_price from categories;
category    |average_price
------------+-------------
business    |$13.73
mod_cook    |$2.99
popular_comp|$22.95
psychology  |$13.50
trad_cook   |$16.45           |
(6 rows)

bookbiz=> select average_price from categories;
pqReadData() -- backend closed the channel unexpectedly.       This probably means the backend terminated abnormally
beforeor while pr
 
ocessing the request.
We have lost the connection to the backend, so further processing is impossible.


Last query doesn't works ! I don't see possible reason if previous queries
work ok. 
My setup: 
bookbiz=> select version();
version
------------------------------------------------------------------
PostgreSQL 6.4.2 on i586-pc-linux-gnu, compiled by gcc egcs-2.91.6
(1 row)
Regards,
    Oleg

BTW, Does somebody already ported to postgreSQL an example script, which created
bookbiz database from the book ?
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83