agora inbox for pljava-dev@postgresql.org
help / color / mirror / Atom feed[Pljava-dev] After an insert, the trigger can't find the row
2+ messages / 0 participants
[nested] [flat]
* [Pljava-dev] After an insert, the trigger can't find the row
@ 2005-08-26 08:24
0 siblings, 1 reply; 2+ messages in thread
From: @ 2005-08-26 08:24 UTC (permalink / raw)
Hello,
My ddr configuration is :
AFTER INSERT ON exploitation.groupe
FOR EACH ROW
EXECUTE PROCEDURE exploitation.alloTrigger();
In my trigger, i would like to do a select to be sure the row is in my
db (because the trigger is fired before the commit if we are in a
transaction).
So, I have in my class fired by trigger a select on my new row.
------------------------------------------------------------------------------------
rsTrigger=td.getNew();
System.out.println("ID "+rsTrigger.getString(1));
int gid_number=rsTrigger.getInt(1);
query="Select * from exploitation.groupe where gid_number="+gid_number;
rs = select.executeQuery(query);
System.out.println("Begin");
while (rs.next()) {
System.out.println("nb ="+rs.getString(1));
}
System.out.println("End");
----------------------------------------------------------------------------------------
I have this info in the log :
ID 170
Select * from exploitation.groupe where gid_number=170
Debut
Fin
--------------------------------------
And the class don't find the last row in the database.
If I launch a select by hand, i find this last row :
SELECT * from exploitation.groupe where gid_number=170;
gid_number | lib_groupe | lic_groupe
------------+------------+------------
170 | a | b
(1 ligne)
I suppose the row is really inserted in the bd after the execution of
the trigger !
Can you help me please ...
Eric
^ permalink raw reply [nested|flat] 2+ messages in thread
* [Pljava-dev] After an insert, the trigger can't find the row
@ 2005-08-26 08:49
parent:
0 siblings, 0 replies; 2+ messages in thread
From: @ 2005-08-26 08:49 UTC (permalink / raw)
Eric BOYER wrote:
> String url="jdbc:postgresql://localhost:5432/bertha";
> Connection con = DriverManager.getConnection(url,"login","password");
> Statement select = con.createStatement();
Ok, that's what I suspected. You establish a whole new session to
another postgresql backend. That session is not in anyway related to
your ongoing transaction, that's why you don't see the changes. The
correct way to obtain a connection is:
Connection conn = DriverManager.getConnection("jdbc:default:connection");
That gives you the *current* connection, i.e. the one where your outer
statement that caused the trigger was fired.
Another tip:
Somehow you make jar file for the PostgreSQL client jdbc driver
available to PL/Java, either you loaded it using sqlj.install_jar or
you've added it to a classpath somewhere. It should be removed altogether.
Regards,
Thomas Hallgren
>
> --------
>
> another test :
>
> In my bd :
> insert into exploitation.goupe values (170,'a','b');
>
> in my log with a select * from exploitation.goupe where
> gid_number=170, the row is not in my db.
>
> in my bd again :
> insert into exploitation.goupe values (171,'c','d');
> in my class file (so int the log) with a
> select * from exploitation.groupe where gid_number=170, the row is
> great in the db
> but with a
> select * from exploitation.groupe where gid_number=171, the row is not
> in the db
>
>
> At the end of the execution of the trigger, in my psql command the
> "select * from exploitation.groupe where gid_number=171" find the row !
>
> Eric
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2005-08-26 08:49 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-08-26 08:24 [Pljava-dev] After an insert, the trigger can't find the row
2005-08-26 08:49 `
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox