Two Laptop Bag*
The moose likes Oracle/OAS and the fly likes copy couple of rows from same table with hiberrnate sequence value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "copy couple of rows from same table with hiberrnate sequence value" Watch "copy couple of rows from same table with hiberrnate sequence value" New topic
Author

copy couple of rows from same table with hiberrnate sequence value

Vallaru smitha
Ranch Hand

Joined: Aug 19, 2008
Posts: 87

Hi,

I am trying to copy couple of rows from same table with hibernate sequence value for column.

insert into emp(ID,name) values ( hibernate_sequence.nextval ,
(select name from emp where ref_id=10)
)


as there are multiple rows in with ref_id equal to 10 i am getting an error single row subquery returns more than one row

can anyone please let me know if there way to accomplish the above.

Thanks in advance
Smitha
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Presumably select name from emp where ref_id=10 returns more than one row? If it does you will need to use a cursor to do this. Open a cursor and for each of your name attributes, select the next value from the sequence and insert them into emp.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: copy couple of rows from same table with hiberrnate sequence value