Advertisement

Procedural Code and CASE Expressions

Abstract

T-SQL has always included support for procedural programming in the form of control-of-flow statements and cursors. One thing that throws developers from other languages off their guard when migrating to SQL is the peculiar three-valued logic (3VL) we enjoy. I will introduce SQL 3VL, which is different from most other programming languages’ simple two-valued Boolean logic, in this chapter. I will also discuss T-SQL control-of-flow constructs, which allow you to change the normally sequential order of statement execution. Control-of-flow statements allowyou to branch your code logic with statements like IF...ELSE..., perform loops with statements like WHILE, and perform unconditional jumps with the GOTO statement. I will also introduce CASE expressions and CASE-derived functions that return values based on given comparison criteria in an expression. Finally, I will finish the chapter by explaining a topic closely tied to procedural code: SQL cursors.

Keywords

Design Pattern Procedural Code Statement Block Administrative Task Error Handling 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Copyright information

© Michael Coles 2008

Personalised recommendations