This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

looping in stored procedure

 
san krish
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked at using a cursor?
 
san krish
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No.I just want to use while or for loop if that works. Is it possible?
 
Paul Clapham
Sheriff
Posts: 21120
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic