Обсуждение: What does this mean ?
Hi
I am receiving this message when doing a begin:
NOTICE: BeginTransactionBlock and not in default state.
What does this mean ?
--
Mario Filipe
mjnf@uevora.pt
http://neptuno.sc.uevora.pt/~mjnf
Вложения
You have already started a transaction and haven't yet finished it. E.g. psql template; BEGIN; BEGIN; Mario Jorge Nunes Filipe wrote: > > Hi > > I am receiving this message when doing a begin: > > NOTICE: BeginTransactionBlock and not in default state. > > What does this mean ? > -- > Mario Filipe > mjnf@uevora.pt > http://neptuno.sc.uevora.pt/~mjnf -- ------------------------------------------------------------ Thomas Reinke Tel: (416) 460-7021 Director of Technology Fax: (416) 598-2319 E-Soft Inc. http://www.e-softinc.com
Thomas Reinke wrote:
>
> You have already started a transaction and haven't yet
> finished it.
>
> E.g.
>
> psql template;
> BEGIN;
> BEGIN;
Not that i don't believe you but i think that in my case that is a tid
bit impossible. The error comes from a php script. On that script i open
the connection, then i do a select and then the begin. So there isn't
anyother begin. I've tryed to run an abort before that but it still
doen't return a result, althoug there is no message error either.
I really need help here, because i really need this thing working with
transactions. Just in case here is the code:
pg_Exec($conn, "abort");
$result = @pg_Exec($conn, "begin");
if (!$result);
$msg ="sac-pcgra (2):".addslashes(pg_ErrorMessage($conn));
$msg = chop($msg);
echo "<script>alert(\"$msg\");history.go(-1)</script>";
pg_Close($conn);
exit;
}
When running this i always get an alert box saying "sac-pcgra(2):".
What is wrong?
Thanks
--
Mario Filipe
mjnf@uevora.pt
http://neptuno.sc.uevora.pt/~mjnf
Вложения
> I really need help here, because i really need this thing working with > transactions. Just in case here is the code: > > pg_Exec($conn, "abort"); > $result = @pg_Exec($conn, "begin"); > if (!$result); > $msg ="sac-pcgra (2):".addslashes(pg_ErrorMessage($conn)); > $msg = chop($msg); > echo "<script>alert(\"$msg\");history.go(-1)</script>"; > pg_Close($conn); > exit; > } > > > When running this i always get an alert box saying "sac-pcgra(2):". > > What is wrong? > In the program, have you forked since opening the connection to the database? If so, you MUST open a new connection in the child process rather than use the same one that is alive in the parent. This could be the problem...
On Fri, Jun 25, 1999 at 05:01:29PM +0100, Mario Jorge Nunes Filipe wrote:
> Thomas Reinke wrote:
> >
> > You have already started a transaction and haven't yet
> > finished it.
> >
> > E.g.
> >
> > psql template;
> > BEGIN;
> > BEGIN;
>
> Not that i don't believe you but i think that in my case that is a tid
> bit impossible. The error comes from a php script. On that script i open
> the connection, then i do a select and then the begin. So there isn't
> anyother begin. I've tryed to run an abort before that but it still
> doen't return a result, althoug there is no message error either.
>
> I really need help here, because i really need this thing working with
> transactions. Just in case here is the code:
>
> pg_Exec($conn, "abort");
> $result = @pg_Exec($conn, "begin");
> if (!$result);
> $msg ="sac-pcgra (2):".addslashes(pg_ErrorMessage($conn));
> $msg = chop($msg);
> echo "<script>alert(\"$msg\");history.go(-1)</script>";
> pg_Close($conn);
> exit;
> }
Here is some code from one of my projects (displays the top 15
speakers in a database of irc transactions). I don't bother to post
a COMMIT in this case because it is just a select. On another system,
I do get warning (not error) messages about not COMMITing transactions,
btw.
$pgconn = pg_connect("socket", "5432", "", "", "slashnet");
$result = pg_exec($pgconn, "BEGIN");
$result = pg_exec($pgconn, "DECLARE foo CURSOR FOR select nick, count(*) as tcoun
t from messages group by nick order by tcount desc");
$result = pg_exec($pgconn, "FETCH 15 IN foo");
$rows = pg_numrows($result);
>
> pg_Exec($conn, "abort");
> $result = @pg_Exec($conn, "begin");
> if (!$result);
> $msg ="sac-pcgra (2):".addslashes(pg_ErrorMessage($conn));
> $msg = chop($msg);
> echo "<script>alert(\"$msg\");history.go(-1)</script>";
> pg_Close($conn);
> exit;
> }
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
Rem
-------------------------------------------------------------------*------------
Remigiusz Sokolowski e-mail: rems@gdansk.sprint.pl * *
-----------------------------------------------------------------*****----------
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...
--
Mario Filipe
mjnf@uevora.pt
http://neptuno.sc.uevora.pt/~mjnf
Вложения
> 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 * *
-----------------------------------------------------------------*****----------