By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,726 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Update rows with ids in CSV value passed to stored procedure

100+
P: 228
Hei all,

I am trying to update rows whose values is in a csv. i.e. 1,2,3

the stored proc looks like this:

Expand|Select|Wrap|Line Numbers
  1. spname(IN ids varchar(100)){
  2.  
  3. update tbl1 SET updaterow=1 WHERE rowid IN FIND_IN_SET(rowid,ids);
  4.  
  5. }
  6.  
Only one row gets updated. Any memory-safe work around this?
Jan 27 '15 #1
Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,347
Find in set returns the index of the occurrence of the first parameter in the second parameter. You don't check the rowid against it, you just need to check that the return value is greater than zero.
Jan 27 '15 #2

100+
P: 228
I understand. Any work around? Is the only way to send the ids one by one for an update?
Jan 27 '15 #3

Rabbit
Expert Mod 10K+
P: 12,347
You don't need a work around, you just need to use the function correctly. Like I said in my earlier post, check that the return value is greater than 0. There's no need for the IN operator nor the additional reference to rowid.
Jan 27 '15 #4

Post your reply

Sign in to post your reply or Sign up for a free account.