X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B928B56381 for ; Thu, 5 May 2005 04:56:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08978-07 for ; Thu, 5 May 2005 07:56:47 +0000 (GMT) Received: from vlo.olsztyn.pl (tranquillity.vlo.olsztyn.pl [80.55.168.86]) by svr1.postgresql.org (Postfix) with ESMTP id B07A356376 for ; Thu, 5 May 2005 04:56:46 -0300 (ADT) Received: by vlo.olsztyn.pl (Postfix, from userid 1000) id 7045D6766B; Thu, 5 May 2005 09:57:19 +0200 (CEST) Date: Thu, 5 May 2005 09:57:18 +0200 From: Pawel Bernat To: pgsql-php@postgresql.org Subject: Re: last value[Scanned] Message-ID: <20050505095718.A26850@vlo> References: <6FE0AEF8FBBD124D8CF3DD26064A096A1222E6@MMDELL.mm.local> <20050504153312.A24041@vlo> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.2.5i In-Reply-To: ; from rwarken@gmail.com on Wed, May 04, 2005 at 04:39:27PM -0300 X-Flush: asmleet X-Discalimer: Of course! X-Operating-System: unix 32bit i686 X-Opinion-About-Mailer: =?iso-8859-2?Q?Mutt_-_jedyny_s=B3uszny?= X-Opinion-About-Header-Reader: 313373 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/16 X-Sequence-Number: 3130 On Wed, May 04, 2005 at 04:39:27PM -0300, Roni Warken wrote: > Right Pawel! If I get the current value, my DB could crash in the next > insertion. > > What about the trigger? Where do I get some examples to practice?but It all depends on your needs :) To save data integrity, you have at least three basic solutions: a) put all queries into transaction. If someting fails in next step, first insert will be canceled, b) write a stored procedure (containing all necessary queries) in a database side, and call this proc in your application, c) create trigger on table - if your second query doesn't need extra parameters coming from application. Samples for a) and b) are in the documentation / examples in postgres package. You have to choose a procedural language first (PHP is available). -- Paweł Bernat; uselessness' lover; select''as email; Slowly and surely the unix crept up on the Nintendo user ...