Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

copy couple of rows from same table with hiberrnate sequence value

 
Vallaru smitha
Ranch Hand
Posts: 87
Firefox Browser Hibernate Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic