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

stored procedure with dual personality

P: 1
I have a long, complicated set of conditions that I would like to use in a MySQL stored procedure to either (a) update a table with the complicated set of conditions in the WHERE clause, or (b) return a single value based on the same set of complicated conditions. I know how to write a stored procedure to do one or the other, but cannot see a way to have one stored procedure, an input parameter to say whether the output will be A or B, and without duplicating the complicated conditions. I am stuck at seeing that A needs an Update statement, and B needs an if-then statement, and both need the same complicated conditions inside the respective statements.

I should add that the complicated conditions are based on the content of other fields in each record. So for option B it is a simple matter of looking at the other parameters for a single case. But for option A, there is a whole table of records that need to be updated where the output for each record depends on the contents of other fields in that record.
Nov 12 '15 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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