Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id EA5BD37C6BF for ; Fri, 10 Oct 2008 06:15:47 -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 50071-05 for ; Fri, 10 Oct 2008 06:15:41 -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 5F7F037C6BD for ; Fri, 10 Oct 2008 06:15:41 -0300 (ADT) Received: from nSoft.lt (unknown [217.117.29.29]) by vilnius.balt.net (Postfix) with ESMTP id 6EC993B9E72; Fri, 10 Oct 2008 12:15:36 +0300 (EEST) Received: from [192.168.16.117] (unknown [192.168.16.117]) by nSoft.lt (Postfix) with ESMTP id 2049FBF073; Fri, 10 Oct 2008 12:21:45 +0000 (GMT) Message-ID: <48EF1D31.5080207@nsoft.lt> Date: Fri, 10 Oct 2008 12:15:29 +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> <48EEF0DA.7040806@nsoft.lt> In-Reply-To: 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/81 X-Sequence-Number: 30537 I don't know a way to edit 2 tables in 1 SQL statement. If you have 2 sql statements then the performance should be almost the same with the function and maybe slightly worse with a trigger. Jagadeesh rašė: > Hi Julius Tuskenis, > > Many thanks for helping me. These are good solutions. But I have some > doubts > Look below > > On Oct 10, 11:06 am, jul...@nsoft.lt (Julius Tuskenis) wrote: > > >> 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. >> >> > I think having triggers would bring performance down. So instead can > we have single > sql update statement to update all four fields of two tables? Just a > crazy idea. > > >> Good luck! >> >> > Thanks for the wish. > These wishes needed to implement smart solution to above problem :) > > -- Julius Tuskenis Programavimo skyriaus vadovas UAB nSoft mob. +37068233050