Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java and SQL

 
Himanshu Rawat
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i don't know where to ask the problem so I'm asking here.

I need to delete some 5000 entries from oracle database through Java.

First approach was to create prepared statement with delete query and then delete one by one. But this approach is not efficient as entries might got 10K and is not constant.

Is there any other way to do it?? Like having PL/SQL procedure which can accept an array, vector something like that??

Please help

Cheers
Rawat
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a reason you can't write SQL along the lines of:

 
Himanshu Rawat
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

hi,

Thanks for quick reply

right now I am doing like this


value = primary key of table

This is called as many time as there are entires which i think is not good.

Comments please??

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swap your equals check to an in clause, e.g.

Be aware Oracle has a limit of 1000 things in a single in clause so you will have to or them together, e.g.:



 
Himanshu Rawat
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul

Can we do something like this



where ARRAY will have all the entries??


 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only if your value data type is a SQL array data type.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic