..oO(bregent)
Quote:
I consider that query very complex and error-prone.
Well it's not pretty. But error prone? |
IMHO yes. If you have to copy such a monster from somewhere or even have
to make adjustments, such code is just painful and very hard to read. At
least for me.
Quote:
It works. Why would it suddenly stop
working? |
It wouldn't, but first you have to get it correctly and in the way you
want into the DB.
Quote:
With all these nested INSTR() calls it also looks quite inefficient.
Maybe, but you probably wouldn't notice any performance issues until you get
to many 10's of thousands of rows. I'm not sure what the OP has in mind for row
counts.
And unless you have different functions available to use within the sproc,
it's not really going to be any better.
What would you do inside a sproc to make it more efficient? |
Good question.
At least I have variables, which can be really helpful for many
algorithms. Additionally there might be other languages available for
writing SPs instead of just pure SQL, which might allow to simply split
the string at the commas and then perform the calculations. Just a few
operations in maybe 2 or 3 lines of code. That's what I was thinking of
in my last reply. And even if there's just pure SQL in the SP, I would
still prefer that, because it allows for nicer queries and reusability.
But I have to admit that I haven't used SPs yet, because I didn't need
them.
Micha