Re: ISOLATION LEVEL SERIALIZABLE

From: "PG Explorer" <pgmail(at)pgexplorer(dot)com>
To: <pgsql-general(at)postgresql(dot)org>, "power2themacs" <power2themacs(at)yahoo(dot)com>
Subject: Re: ISOLATION LEVEL SERIALIZABLE
Date: 2002-03-26 19:05:18
Message-ID: 001101c1d4f9$2e32a220$c80ba8c0@sabex.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

You should create a trigger after insert on table1 to insert in table2
that should do it.
Furthermore you should change table2.id to int4 or int 8 and use the serial
from table1

http://www.pgexplorer.com
GUI tool for Postgres

----- Original Message -----
From: "power2themacs" <power2themacs(at)yahoo(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Sent: Tuesday, March 26, 2002 8:47 PM
Subject: [GENERAL] ISOLATION LEVEL SERIALIZABLE

> I am using 7.2 and JDBC. I have a very simple situation where I
> insert an item with a primary key which is a SERIAL. In the same
> transaction I need to insert a reference in a separate table to this
> item. Of course, race conditions could occur if I didn't use this
> special isolation level. But is there no way in which I could use
> row-level locking instead? Certainly, I am not updating the table I
> just inserted to, so the FOR UPDATE would never unlock. Is the
> isolation level my only option? I noticed that psql displays the oid
> after an INSERT. That would be exactly what I need but JDBC doesn't
> seem to offer this.
>
> (Right now I set the isolation level and just get the SERIAL's current
value.)
>
> |---table1----------------| |---table2-----------------|
> | id SERIAL PRIMARY KEY | | id SERIAL REFERNCES table1 |
>
>
> Short version:
> I just inserted into table1 and need these in the same transaction.
> How can I get the id I just inserted into table2? Thanks folks.
> --
> ><><><><><><><><><><><><
> power2themacs(at)yahoo(dot)com
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sonia Sanchez Diaz 2002-03-26 19:14:35 Performance in subconsult
Previous Message power2themacs 2002-03-26 18:47:06 ISOLATION LEVEL SERIALIZABLE