Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

CHAPTER 14 SQL/PSM Basics > SQL/PSM Control Structures

SQL/PSM Control Structures

As mentioned, control structures do one of two things: They check logical conditions and branch program execution, or they repeat (iterate) over a condition unit it is met or they’re instructed to exit. In MySQL, the if, elseif, else, and CASE statements are conditional structures, while loops let you repeat instructions or iterate (move over rows in a cursor one-by-one) across data.

If and CASE statements work on comparing values. Table 14-3 lists the valid comparison operators available in SQL/PSM stored programs.

Table 14-3 shows a couple of comparison operators that might raise an eyebrow and a bit of curiosity: the not equal (<>) and the null safe operator (<=>). They’re very different things, because the <> only works when both values contain a value and the values are different. The <> returns false when one of the values contains a null, whereas the <=> returns true when both variables are nulls.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial