aspose file tools*
The moose likes JDBC and the fly likes looping in stored procedure 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 » Databases » JDBC
Bookmark "looping in stored procedure" Watch "looping in stored procedure" New topic
Author

looping in stored procedure

san krish
Ranch Hand

Joined: Aug 11, 2010
Posts: 41
Hi,
I have a query like this,


select email as vEmail from users where id in (217211,217521,217641)

Now this query returns 3 email id's. I have to loop through the vEmail and assign them to different local variables in stored procedures.

like email for 217211 is stored in vEmail1
217521 in vEmail2
217641 in vEmail3

Can somehow help me in this looping?
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
Have you looked at using a cursor?
san krish
Ranch Hand

Joined: Aug 11, 2010
Posts: 41
No.I just want to use while or for loop if that works. Is it possible?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

First you should mention what language you're writing this stored procedure in. (It probably isn't Java.) And second you should explain how you expect to figure out which of the three e-mail addresses you get in that result set belongs to which ID, given that you don't have the ID in the result set.
san krish
Ranch Hand

Joined: Aug 11, 2010
Posts: 41
Hi Im using Java.
And my result set contains all the 3 email id's.
whatever i give in the 'IN' clause, i want to name it acc as email1, email2, email3.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: looping in stored procedure