Re: i need you help about postgresql(rollback)

From: Jaime Casanova <systemguards(at)gmail(dot)com>
To: Nee(dot)Mem(倪明) <accp(at)citiz(dot)net>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: i need you help about postgresql(rollback)
Date: 2005-07-14 18:12:26
Message-ID: c2d9e70e05071411123136406a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 7/13/05, Nee.Mem(倪明) <accp(at)citiz(dot)net> wrote:
> systemguards,hi!
> i see you wrote on this page
> http://archives.postgresql.org/pgsql-general/2005-07/msg00319.php
>
> test exsample:
> create or replace function test()
> returns void as
> '
> begin
> delete from regiondata;
> rollback;
> end;
> 'language 'plpgsql';
> but exception a error: CONTEXT: PL/pgSQL function "test" line 3 at SQL statement
> Use others' words :
> >It is important not to confuse the use of BEGIN/END for grouping statements
> > in PL/pgSQL with the database commands for transaction control. PL/pgSQL's
> > BEGIN/END are only for grouping; they do not start or end a transaction
> and can you tell me how to use rollback work in 'pgsql' function? and give me a exsample?
>

As Alvaro told you can write ROLLBACK... if you are using pgsql 8.x.x
then you can use exceptions... Alvaro gives you the examples... When a
statement gives an error, it will go to the exception an all
statements in the block will be rolled back.

If you are using pgsql 7.x.x or lower... you will get an error an all
your transaction will be rolled back

--
regards,
Jaime Casanova
(DBA: DataBase Aniquilator ;)

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-07-14 18:28:51 Re: Standalone Parser for PL/pgSQL
Previous Message Tom Lane 2005-07-14 17:51:12 Re: ERROR: could not open relation