Skip site navigation (1) Skip section navigation (2)

Re: help with version checking

From: Arnau <arnaulist(at)andromeiberica(dot)com>
To:
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: help with version checking
Date: 2006-12-28 18:20:55
Message-ID: 45940B07.4010708@andromeiberica.com (view raw or flat)
Thread:
Lists: pgsql-sql
Arnau wrote:
> Tom Lane wrote:
>> Arnau <arnaulist(at)andromeiberica(dot)com> 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(at)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
> 
> 

I paste the script I have created:

CREATE OR REPLACE FUNCTION check_version() RETURNS void
AS '
DECLARE
   v_version VARCHAR;

BEGIN
   SELECT version INTO v_version FROM agenda_version WHERE id = 1;

   IF v_version <> ''1.0.0.0'' THEN
     RAISE EXCEPTION ''This script needs Agenda version 1.0.0.0, 
detected version %'', v_version;
   END IF;

END;
' LANGUAGE 'plpgsql';

SELECT check_version();

UPDATE agenda_version set version = '1.0.0.1' where id = 1;



-- 
Arnau

In response to

Responses

pgsql-sql by date

Next:From: Chris DunworthDate: 2006-12-28 18:32:51
Subject: Re: help with version checking
Previous:From: ArnauDate: 2006-12-28 18:14:58
Subject: Re: help with version checking

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group