• jcelko212 32090 - Wednesday, December 20, 2017 8:24 PM

    tomyang03 - Monday, December 18, 2017 1:46 PM

    An integer salary? A company where the personnel have hundred character names written in Unicode Chinese? Why don’t you know that the expression “@generic_id = NULL†will always test to a constant value of unknown? The department identifier cannot be an integer or any other numeric; you’re not do any math on it (do you often take the square root of your credit card numbers?)

    There is no such crap as @id in RDBMS. An identifier must identifysomething in particular, not some just vague generic entity.
    SQL is a declarative language,, So we don’t like to use local variableslike are doing.

    Using functions, because you don’t know how to write the SQL, prevents the optimizer from being able to do anything. That used to work in the old procedural languages.

    Finally,you seem to believe that a manager is a totally different creature from an employee. In a properly designed schema, being a manager would be the value of a job title attribute. You’re still building assembly language pointer chains, and not writing RDBMS at all!

    I would suggest you look up the nested set model of hierarchies and use that to build your personnel tables.

    Although in general I agree with your post, the tone you presented it in is slightly aggressive.  Not everyone is a trained DBA or developer and we would like to encourage accidental DBAs or part time SQL writers to ask questions without fear of being insulted or degraded, regardless of how simple or obvious a solution might be to us. 

    Perhaps the solution is to not only criticise as you have done, but rather to offer advice and examples in a manner that a layman can understand as I think this person may be.