Intermediate
Q: | |
3-10. | You can rewrite this block of code as follows: DECLARE total_sales NUMBER := sales_for_year (company_id=>1056, yearnum=>1998); no_revenue BOOLEAN; BEGIN no_revenue := total_sales <= 0; END; You do not need an IF statement in situations where you assign the value to a Boolean variable. Instead, you can assign the expression that would have appeared in the IF statement, directly to the Boolean. Note that if total_sales is set to NULL, no_revenue is set to NULL in both cases. |
Q: | |
3-11. | In this case, you can’t quite obtain the same behavior by replacing the IF statement with a direct assignment. You might consider the following statement: no_revenue := total_sales <= 0; But you run into trouble if total_sales is NULL. The original code would have set no_revenue to FALSE if total_sales was NULL, since it would cause the ELSE clause to execute. If you replace it with a single line assignment, no_revenue is set to NULL instead of FALSE. |
Q: | |
3-12. | The queue_order_for_addtl_parts procedure is never executed, regardless of the values for order_date, order_total, and min_order_total. For this procedure to run, order_date must be less than or equal to SYSDATE. If this is the case, the second condition would also be TRUE, and then fill_order is run for “LOW PRIORITY”. When working with IF-ELSIF statements, it is extremely important that you make sure the Boolean expressions are mutually exclusive. |
Q: | |
3-13. | There is no difference logically between these two statements. The only difference ... |
Get Oracle PL/SQL Programming: A Developer's Workbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.