This section gives you some suggested answers to the questions in Lab 7.1, with discussion related to how those answers resulted. The most important thing to realize is whether your answer works. You should figure out the implications of the answers here and what the effects are from any different answers you may come up with. 7.1.1 Answers
Notice that before you calculate the square root of a number, you can check to see if the number is greater than or equal to 0 with the help of the IF-THEN-ELSE statement. If the number is negative, the message "A number cannot be negative" is displayed on the screen. When the value of -4 is entered for the variable v_num , this script produces the following output: Enter value for sv_num: -4 old 2: v_num NUMBER := &sv_num; new 2: v_num NUMBER := -4; A number cannot be negative PL/SQL procedure successfully completed. |