• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

copy couple of rows from same table with hiberrnate sequence value

 
Ranch Hand
Posts: 87
Hibernate Firefox Browser 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE 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.
    Bookmark Topic Watch Topic
  • New Topic