Quote:
|
I'm an excellent SQL programmer, and find it necessary to use IF/THEN logic frequently.
|
No, you are not even a good SQL programmer yet. I am being objective, not mean.
Go look at the code you posted for removing non-digit characters from phone numbers in another thread. You wrote a 1970's BASIC function in T-SQL, not good SQL. You did not follow ISO-11179 rules for names, your function will have to be invoked row-by-row (ever hear the RDBMS slang RBAR? Look it up; Jeff Modem coined it), you scan the input string character-by-character, left to right. This is how a punch card or mag tape works. You did nothing in a declarative or set-oriented way!
I replaced your code with
one update statement that will run orders of magnitude faster and the code is portable. You literally posted a version of a bad example I use in my SQL classes.
You had local variables to add the overhead of disk access. But more than that, it means you do not understand the declarative/functional model of programming. Please read
An Introduction to Functional Programming by Greg Michaelson, if it will help. Or talk to a LISP, APL or F# programmer.
Since SQL got the CASE expression in SQL-92, I have not used IF-THEN logic. Primitive recursive function theory guarantees I can do this! I do not write UDFs, or TRIGGERs either. My rule of thumb is no more than five triggers in your
whole career, and most of those should be INSTEAD OF triggers.