PL/SQL Quiz Answers and Corrections

Module 3 Quiz Answers

Below are the corrected answers and statements from the quiz:

  1. Structured Query Language (SQL) is considered a procedural language. False
  2. PL/SQL fully supports SQL data types. True
  3. The term anonymous blocks refers to blocks of code that are not stored for reuse and do not exist after being executed. True
  4. The BEGIN section of a PL/SQL block contains code that creates variables, cursors, and types. False (This belongs in the DECLARE section.)
  5. Assignment statements are used to put or change the values of variables. True
  6. A disadvantage of using the %TYPE attribute is that there is a slight performance hit in that the database server must look up the data type from the data dictionary. True
  7. A collection is a data type that can store multiple values of different data types as one unit. False (Collections store multiple values of the same data type.)
  8. A scalar variable can hold multiple values whereas a composite variable can hold only a single value. False (Scalar holds one value; composite/collection holds multiple.)
  9. A variable declared with a record type can hold one row of data consisting of a number of column values. True
  10. When placing data into a table of records variable, you must indicate the field that will hold the value but you need not indicate the row. False (You must indicate both the row index and the field.)
  11. SQL is NOT a ____. Procedural language
  12. All of the following are considered to be programming languages, except ____. Oracle (Oracle is a database system/company, not a language itself in this context.)
  13. Which of the following statements is true? Oracle considers PL/SQL to be a procedural language extension of SQL.
  14. Procedural languages allow developers to ____. Perform decision-making logic
  15. The term portability refers to the ability of PL/SQL to ____. Run on any platform that Oracle can run on
  16. Which of the following is considered the brains behind the screens? Programming logic
  17. Which of the following serves as a visual representation of a database? ERD (Entity-Relationship Diagram)
  18. The only required sections of a PL/SQL block are the ____ sections. BEGIN & END
  19. The ____ section of a PL/SQL block contains code that creates variables, cursors, and types. DECLARE
  20. ____ are used to change the values of variables. Assignment statements
  21. The ____ section of a PL/SQL block contains handlers that allow you to control what the application will do if an error occurs when the executable statements are processed. EXCEPTION
  22. Which of the following lines of code is syntactically correct?
    
    DECLARE
    order NUMBER(3);
    departure DATE;
    BEGIN
    ---- executable statements ---
    END;
    
  23. Which of the following initializes the variable order?
    
    DECLARE
    order NUMBER(2) := 0;
    departure DATE;
    BEGIN
    ---- executable statements ---
    END;
    

Question 24

Which of the following PL/SQL blocks requires the variable to always contain a particular value within the block?


DECLARE
order CONSTANT NUMBER(2,2) := .02;
departure DATE;
BEGIN
---- executable statements ---
END;

Question 25


DECLARE
order NUMBER(2) := 4;
total_amt NUMBER(2);
BEGIN
total_amt := order * 8;
END;

According to the statement block above, what value is stored in the variable total_amt? 32

Question 26

Which of the following statement blocks correctly uses a scalar variable in an assignment statement?


DECLARE
order NUMBER(2) := 4;
total_amt NUMBER(2);
BEGIN
total_amt := 12 * order;
END;

Question 27

A(n) ____ is a variable that can store and handle multiple values of the same data type as one unit. Collection

Question 28

Which of the following code fragments correctly creates a record data type that will hold four variables?


DECLARE
TYPE type_basket IS RECORD (
basket bb_basket.idBasket%TYPE,
created bb_basket.dtcreated%TYPE,
qty bb_basket.quantity%TYPE,
sub bb_basket.subtotal%TYPE );
rec_basket type_basket;
BEGIN
--- executable code ---
END;

Question 29


DECLARE
TYPE type_basket IS RECORD(
basket bb_basket.idBasket%TYPE,
created bb_basket.dtcreated%TYPE,
total bb_basket.cost%TYPE,
qty bb_basket.quantity%TYPE,
sub bb_basket.subtotal%TYPE);
rec_basket type_basket;
BEGIN
--- executable code ---
END;

According to the code fragment above, which variable is declared using the type_basket data type? rec_basket