Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Getting reference from a newly inserted object

Re: Getting reference from a newly inserted object

From: Jim Kennedy <kennedy-downwithspammersfamily_at_attbi.net>
Date: Fri, 6 Jan 2006 07:34:34 -0800
Message-ID: <_5GdnVHqS-AKECPeRVn-pQ@comcast.com>

"jerry" <jerry82006chen_at_gmail.com> wrote in message news:1136561268.819233.177620_at_f14g2000cwb.googlegroups.com...
> HI
> I am troubling in getting reference of an user defined type after
> inserted it into a table.
> For example, I use a java program to insert an user defined object:
>
> .
> .
> .
> OraclePreparedStatement pstmt =
> (OraclePreparedStatement)conn.prepareStatement ("insert into My_Table
> values (?)");
> pstmt.setObject(1,this);
> pstmt.execute();
> .
> .
> .
>
> I can't use another select statement (ex. select ref(myref) from
> My_Table where My_Table.ID=?) to retrieve the record just inserted due
> to there is no constraint on all the columns of My_Table.
> Please help to get the reference of a newly inserted object, thanks a
> lot.
>

Then you have a poor design. It makes no sense not to have a primary key, how do you distinguish one row from another? Fix the design. There are ways to accomplish what you want, but it would be encouraging poor design and cause other problems down the road.
Jim Received on Fri Jan 06 2006 - 09:34:34 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US