PL/SQL Quiz Answers and Corrections
Module 3 Quiz Answers
Below are the corrected answers and statements from the quiz:
- Structured Query Language (SQL) is considered a procedural language. False
- PL/SQL fully supports SQL data types. True
- The term anonymous blocks refers to blocks of code that are not stored for reuse and do not exist after being executed. True
- The
BEGINsection of a PL/SQL block contains code that creates variables, cursors, and types. False (This belongs in theDECLAREsection.) - Assignment statements are used to put or change the values of variables. True
- A disadvantage of using the
%TYPEattribute is that there is a slight performance hit in that the database server must look up the data type from the data dictionary. True - 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.)
- 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.)
- A variable declared with a record type can hold one row of data consisting of a number of column values. True
- 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.)
- SQL is NOT a ____. Procedural language
- 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.)
- Which of the following statements is true? Oracle considers PL/SQL to be a procedural language extension of SQL.
- Procedural languages allow developers to ____. Perform decision-making logic
- The term portability refers to the ability of PL/SQL to ____. Run on any platform that Oracle can run on
- Which of the following is considered the brains behind the screens? Programming logic
- Which of the following serves as a visual representation of a database? ERD (Entity-Relationship Diagram)
- The only required sections of a PL/SQL block are the ____ sections.
BEGIN&END - The ____ section of a PL/SQL block contains code that creates variables, cursors, and types.
DECLARE - ____ are used to change the values of variables. Assignment statements
- 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 - Which of the following lines of code is syntactically correct?
DECLARE order NUMBER(3); departure DATE; BEGIN ---- executable statements --- END; - 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
