Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

updation of multiple rows

 
singh udit
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a mail management system application which has mailboxes and emails in it. The architecture is like this:
there is a table called email which contains all the emails for all the users, irrespective of the mailbox. there is a field emailid for each email(primary key) and mailbox id for a particular emailid.
Now according to application ,user of one mailbox can pull emails from other mailbox, to its own mailbox. For this user just has to specify the mailbox and the number of emails to be pulled to his/her mailbox, from the specified mailbox.
Now for this operation, following things are done:
1. Select all the emailids for a specified mailbox.
2. Filter out the first n number of emailids(this is same as the number of emails user wants to pull).
3. Update the mailboxid for each email in the email table.
(for this seperate query is fired for each email).
So if the user trys to pull a huge number, say 30-40 emails from a mailbox, it takes a lot of time.
Can somebody tell me a better way to do this.
Should I use stored procedure for this, but this won't decrease the number of queries.
or should I use prepared statement.
Also can the concept of cursor be helpful here?
I don't want to modify the already existing tables.
Your suggestion will be very helpful.
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic