Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id E86919F9F47 for ; Thu, 28 Dec 2006 14:32:58 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 59615-03 for ; Thu, 28 Dec 2006 14:32:46 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from elasmtp-junco.atl.sa.earthlink.net (elasmtp-junco.atl.sa.earthlink.net [209.86.89.63]) by postgresql.org (Postfix) with ESMTP id 73AA39F938C for ; Thu, 28 Dec 2006 14:32:53 -0400 (AST) Received: from [68.164.10.83] (helo=[192.168.26.5]) by elasmtp-junco.atl.sa.earthlink.net with asmtp (Exim 4.34) id 1H003g-0008Fy-8o; Thu, 28 Dec 2006 13:32:52 -0500 Message-ID: <45940DD3.3040509@earthcomber.com> Date: Thu, 28 Dec 2006 12:32:51 -0600 From: Chris Dunworth User-Agent: Thunderbird 1.5.0.8 (X11/20061115) MIME-Version: 1.0 To: arnaulist@andromeiberica.com CC: pgsql-sql@postgresql.org Subject: Re: help with version checking References: <000001c72aa7$e705f1e0$0b00a8c0@tedy> <45940403.4010909@andromeiberica.com> <21284.1167328587@sss.pgh.pa.us> <459409A2.9020103@andromeiberica.com> In-Reply-To: <459409A2.9020103@andromeiberica.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-ELNK-Trace: f95dbdb9e0397947e4766830010d2531239a348a220c2609deb5b7b4b029f155f57a42533b7545b393caf27dac41a8fd350badd9bab72f9c350badd9bab72f9c X-Originating-IP: 68.164.10.83 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/182 X-Sequence-Number: 27138 Can you do the whole thing inside a transaction context (both the version check and the updates)? The exception should cause the transaction to bail out, and the updates won't proceed. Thus: BEGIN; SELECT check_version(); UPDATE agenda_version set version = '1.0.0.1' where id = 1; COMMIT; I tried it with your script and it seemed to work for me. Hope this helps... -chris Arnau wrote: > Tom Lane wrote: >> Arnau writes: >>> I don't want, if it's possible, to create a function. >> >> Unlike Oracle, PG makes a strong distinction between SQL and >> programmable languages (including plpgsql). You can't write >> plpgsql code without putting it into a function. >> >> regards, tom lane >> > > I've tried Daniel's suggestion but the Raise doesn't terminate the > script execution, so if doesn't do what I need. Notice the Update 1 > > arebassa@beowulf:~$ psql -d dermagier -f upgrade_agenda.sql > CREATE FUNCTION > psql:upgrade_agenda.sql:16: ERROR: This script needs Agenda version > 1.0.0.0, detected version 1.0.0.1 > UPDATE 1 > >