I'd probably make a small change to make this a little cleaner.
Specifically, change check_version() to take an argument, which is the
needed version, and check this against the current value in
agenda_version, throwing the exception if they don't match. Once you've
written this, you'll never
Hi all,
Thanks for all replies, taking into account all your suggestions and
my google research I arrived to the next script. I'd like to know your
opinion. Hopefully this will be useful for somebody else.
--used to stop the script execution on any error
In GNUmed we have created a function
gm_concat_table_structure()
in
http://cvs.savannah.gnu.org/viewcvs/gnumed/gnumed/server/sql/gmSchemaRevisionViews.sql?rev=1.6&root=gnumed&view=log
which returns a reproducable, human-readable TEXT
concatenation of all the relevant parts of t
> I tried to do the following in PostgreSQL:
>
> DECLARE
>v_version VARCHAR;
>
> BEGIN
>SELECT version INTO v_version FROM 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;
>
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 t
Arnau wrote:
Tom Lane wrote:
Arnau <[EMAIL PROTECTED]> 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.
Tom Lane wrote:
Arnau <[EMAIL PROTECTED]> 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.
Arnau <[EMAIL PROTECTED]> 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,
Hi Daniel,
You should define a PL/PGSQL function such as:
CREATE OR REPLACE FUNCTION check_version()
RETURNS void
AS $$
DECLARE
v_version VARCHAR;
BEGIN
SELECT version INTO v_version FROM version WHERE id = 1;
IF v_version <> '1.0.0.0' THEN
RAISE EXCEPTION 'This script needs Agen
Hi all!,
I've got the following problem and I don't know how to solve it in
PostgreSQL.
I'd like to add a version checking to my db scripts. That is, I have
the db creation scripts and the changes/upgrade script, and there is a
table inside each db that holds the version of script execut
10 matches
Mail list logo