Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 80C1C37BEDD for ; Fri, 10 Oct 2008 03:06:31 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 17670-02 for ; Fri, 10 Oct 2008 03:06:28 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from vilnius.balt.net (vilnius.balt.net [195.14.170.14]) by postgresql.org (Postfix) with ESMTP id 875A537BE97 for ; Fri, 10 Oct 2008 03:06:28 -0300 (ADT) Received: from nSoft.lt (unknown [217.117.29.29]) by vilnius.balt.net (Postfix) with ESMTP id 6E1053B3224; Fri, 10 Oct 2008 09:06:25 +0300 (EEST) Received: from [192.168.16.117] (unknown [192.168.16.117]) by nSoft.lt (Postfix) with ESMTP id 88A39BF060; Fri, 10 Oct 2008 09:12:36 +0000 (GMT) Message-ID: <48EEF0DA.7040806@nsoft.lt> Date: Fri, 10 Oct 2008 09:06:18 +0300 From: Julius Tuskenis User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: Jagadeesh CC: pgsql-admin@postgresql.org Subject: Re: can I update multiple table at a time? References: <4ba626d0-b2b5-4421-8df1-1bb39d4a858b@t39g2000prh.googlegroups.com> In-Reply-To: <4ba626d0-b2b5-4421-8df1-1bb39d4a858b@t39g2000prh.googlegroups.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200810/76 X-Sequence-Number: 30532 Hi, Jagadeesh I would suggest you 2 solutions: 1. to use a function to edit these fields. That way you will be sure that you will not forget to update both tables. 2. use a trigger on master table. If I understand you - the history table could be filled using trigger, when data in master table changes. That way you could change only master table in your application. Good luck! Jagadeesh rašė: > Hello Gurus, > > Is it possible to update two table using single sql statement? huh? > let me be clear > > I have table master with state and date field. And in history table I > have same fields i.e., state and date. I'm writing an update statement > to set 'open' state records to 'closed' state after 7. both table can > be joined using id. > > Any thoughts? > > Thanks > > -- Julius Tuskenis Programavimo skyriaus vadovas UAB nSoft mob. +37068233050