One of the topics we covered in my second day of instructor led training was control structures. Here a some tips and specifics I learned. The PL/SQL IF statement treats NULL and FALSE the same way. They fail the IF test and cause the code to go on. Also if you include an ELSE clause in a IF statement, then one of the blocks in the construct is guaranteed to execute.
The CASE expression is one that I was familiar with. Something I learned was that the CASE expression itself returns a NULL if none of the cases matched. I also was told that a CASE expression performs similar to the IF ... THEN construct.
Loops where you perform the test at the top are called "top tested loops". That makes sense. A WHILE loop is an example of that. However a LOOP where you have the WHEN EXIT clause at the top is also a top tested loop. FOR loops can have ranges that are themselves variables. They do not have to be literals. If the upper and lower bounds of a FOR loop are the same, the loop executes exactly once. Note that you cannot change the value of the FOR loop iterator manually inside the loop. In Oracle 11g, the CONTINUE statement can be used in any loop to make it move on to the next iteration immediately.
Reproducing a Race Condition
-
We have a job at work that runs every Wednesday night. All of a sudden, it
aborted the last 2 weeks. This caused some critical data to be late. The
main ...