Re: [INTERFACES] object id

Lists: pgsql-interfacespgsql-jdbc
From: Martin Schild <maet(at)gmx(dot)de>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: object id
Date: 2001-03-05 11:06:28
Message-ID: 3AA37334.20564E8C@gmx.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-interfaces pgsql-jdbc

Hi,

I'm using the setBytes() method of jdbc to store a large object to
database. Now i want to store the object id to another table. Is there a

possibility to get the oid of an object directly after the object is
stored to store this id into another table.

thanks,
Martin


From: Peter T Mount <peter(at)retep(dot)org(dot)uk>
To: Martin Schild <maet(at)gmx(dot)de>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: object id
Date: 2001-03-06 11:57:11
Message-ID: 983879831.3aa4d097bf217@webmail.retep.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-interfaces pgsql-jdbc

Quoting Martin Schild <maet(at)gmx(dot)de>:

> Hi,
>
> I'm using the setBytes() method of jdbc to store a large object to
> database. Now i want to store the object id to another table. Is there
> a
>
> possibility to get the oid of an object directly after the object is
> stored to store this id into another table.

setBytes() actually stores the large object's OID in that column, so to get the
oid, simply use getInt() or getString() on the same column.

Only getBytes() & get*Stream() methods (as well as the set* equivalents)
actually operate on the large object itself. The others would see just the oid
value.

Peter

--
Peter Mount peter(at)retep(dot)org(dot)uk
PostgreSQL JDBC Driver: http://www.retep.org.uk/postgres/
RetepPDF PDF library for Java: http://www.retep.org.uk/pdf/


From: maet(at)gmx(dot)de
To: Peter T Mount <peter(at)retep(dot)org(dot)uk>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: object id
Date: 2001-03-06 15:40:50
Message-ID: 8085.983893250@www36.gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-interfaces pgsql-jdbc

> Hi,
>
> I'm using the setBytes() method of jdbc to store a large object to
> database. Now i want to store the object id to another table. Is there
> a
>
> possibility to get the oid of an object directly after the object is
> stored to store this id into another table.

setBytes() actually stores the large object's OID in that column, so to get
the
oid, simply use getInt() or getString() on the same column.
Only getBytes() & get*Stream() methods (as well as the set* equivalents)
actually operate on the large object itself. The others would see just the
oid value.

Peter

O.K. but is it possible to get the oid during or directly after inserting
the object into the table without a query to find the column again? I want to
insert an object at the same time into different tables and they should have
the same oid so i can use a join on these tables.

thanks,
Martin

--
Sent through GMX FreeMail - http://www.gmx.net


From: Peter Mount <peter(at)retep(dot)org(dot)uk>
To: maet(at)gmx(dot)de
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: object id
Date: 2001-03-12 16:11:08
Message-ID: 5.0.2.1.0.20010312160856.0216c080@mail.retep.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-interfaces pgsql-jdbc

At 16:40 06/03/01 +0100, maet(at)gmx(dot)de wrote:
> > Hi,
> >
> > I'm using the setBytes() method of jdbc to store a large object to
> > database. Now i want to store the object id to another table. Is there
> > a
> >
> > possibility to get the oid of an object directly after the object is
> > stored to store this id into another table.
>
>
>setBytes() actually stores the large object's OID in that column, so to get
>the
>oid, simply use getInt() or getString() on the same column.
>Only getBytes() & get*Stream() methods (as well as the set* equivalents)
>actually operate on the large object itself. The others would see just the
>oid value.
>
>Peter
>
>
>O.K. but is it possible to get the oid during or directly after inserting
>the object into the table without a query to find the column again? I want to
>insert an object at the same time into different tables and they should have
>the same oid so i can use a join on these tables.
>
>thanks,
>Martin

Hmm, not really. The only oid you can get is one from an Insert, but thats
for the most recent row inserted.
The only way is to create the blob first, then insert into both tables
afterwards.

Peter


From: maet(at)gmx(dot)de
To: Peter Mount <peter(at)retep(dot)org(dot)uk>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: object id
Date: 2001-03-12 18:22:26
Message-ID: 378.984421346@www32.gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-interfaces pgsql-jdbc

>Hmm, not really. The only oid you can get is one from an Insert, but thats
>for the most recent row inserted.

How do i get the oid from the blob of the most recent row inserted?

thanks,
Martin

--
Sent through GMX FreeMail - http://www.gmx.net


From: Peter Mount <peter(at)retep(dot)org(dot)uk>
To: maet(at)gmx(dot)de
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [INTERFACES] object id
Date: 2001-03-12 20:12:20
Message-ID: 5.0.2.1.0.20010312201101.00a27990@mail.retep.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-interfaces pgsql-jdbc

At 19:22 12/03/01 +0100, maet(at)gmx(dot)de wrote:
> >Hmm, not really. The only oid you can get is one from an Insert, but thats
> >for the most recent row inserted.
>
>
>How do i get the oid from the blob of the most recent row inserted?

The only way is to re-query the row as only the oid of the row is returned
during the insert.

The only other way is to use the largeobject api (not JDBC) and then you
have the oid before any inserts.

Peter