X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id E81359DCD06 for ; Mon, 5 Dec 2005 15:22:29 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19203-03 for ; Mon, 5 Dec 2005 15:22:29 -0400 (AST) X-Greylist: delayed 01:00:03.76216 by SQLgrey- Received: from swip.net (mailfe04.swip.net [212.247.154.97]) by postgresql.org (Postfix) with ESMTP id 196199DCD05 for ; Mon, 5 Dec 2005 15:22:25 -0400 (AST) X-T2-Posting-ID: acesPao/7XUisZxL6cesKg== X-Cloudmark-Score: 0.000000 [] Received: from [213.100.41.61] (HELO [192.168.0.46]) by mailfe04.swip.net (CommuniGate Pro SMTP 5.0.2) with ESMTP id 37394984 for pgsql-sql@postgresql.org; Mon, 05 Dec 2005 19:22:20 +0100 Message-ID: <4394855E.6060201@kth.se> Date: Mon, 05 Dec 2005 19:22:22 +0100 From: Erik Sigra User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051014) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Database query: Notification about change? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200512/24 X-Sequence-Number: 23566 Hi, I plan to develop an application that is somewhat like a spreadsheet with cells containing formulas. When a cell value is changed, things must be updated. But the formulas can contain database queries, which means that the cell has to be notified when the database changes in such a way that the result of the query changes. How is this done? I would really like to avoid recalculating the whole thing for each change to the database. I looked in my database book and read about materialized views and triggers. It seems like I should do the following: 1. Make a materialized view from the query. 2. Add a trigger for changes to this view. 3. Make the trigger notify the application program when it is trigged. Would this be possible? (I was planning to use Qt for application programming and database access.) Thanks, Erik