Re: [GENERAL] What does this mean ? - Mailing list pgsql-general

From Remigiusz Sokolowski
Subject Re: [GENERAL] What does this mean ?
Date
Msg-id Pine.GS4.4.02A.9906281334501.13057-100000@netra.gdansk.sprint.pl
Whole thread Raw
In response to Re: [GENERAL] What does this mean ?  (Mario Jorge Nunes Filipe <mjnf@neptuno.sc.uevora.pt>)
List pgsql-general
> Remigiusz Sokolowski wrote:
> > Error is that You just dont END your transaction
> > before pg_Close You should have a line pg_Exec( $conn, "END;" );
> > pg_Close closes Your connection, but doesn't end Your transactions
>
>     Ok! I'll give it a try ut i find that to be wierd since the code only
> enters that section that i sent before if the exec doesn't return
> anything usefull...
>
But as I remember well (I've deleted previous mails)
Your pg_Exec($conn, "BEGIN;"); call was before "if" statement -
and pg_Close( $conn ) and pg_Exec( $conn, "END;") (if You add it) inside
if - so there are two possible ways of programm flow
First one - You connect to database, open transaction and if "if"
condition is true there are executed statement inside "if" - this should
lead us to point when all is ok - and transaction and connection are
closed

if "if" condition is false then You have an open transaction and no end.

so the whole piece of code should look like:

pg_Connect
pg_Exec( $conn, "BEGIN;");
if condition {
    some things, You wanna do
    pg_Exec( $conn, "END;" );
} else {
    pg_Exec( $conn, "ABORT;")
}
pg_Close( $conn )

I don't remember well, so I could be wrong
    Rem


-------------------------------------------------------------------*------------
Remigiusz Sokolowski      e-mail: rems@gdansk.sprint.pl           * *
-----------------------------------------------------------------*****----------


pgsql-general by date:

Previous
From: "Hub.Org News Admin"
Date:
Subject: ...
Next
From: Chris Bitmead
Date:
Subject: Re: [GENERAL] Re: Data warehousing