Thread: object id

object id

From
Martin Schild
Date:
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





Re: object id

From
Peter T Mount
Date:
Quoting Martin Schild <maet@gmx.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@retep.org.uk
PostgreSQL JDBC Driver: http://www.retep.org.uk/postgres/
RetepPDF PDF library for Java: http://www.retep.org.uk/pdf/


Re: object id

From
maet@gmx.de
Date:
> 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



Re: object id

From
Peter Mount
Date:
At 16:40 06/03/01 +0100, maet@gmx.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



Re: object id

From
maet@gmx.de
Date:
>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