Professional Documents
Culture Documents
Oracle 11g PL SQL Programming 2nd Edition Casteel Test Bank
Oracle 11g PL SQL Programming 2nd Edition Casteel Test Bank
TRUE/FALSE
1. A function is quite similar to a procedure in that it is a program unit that achieves a task, can receive
input values, and returns values to the calling environment.
2. The main difference between functions and procedures is that a function is part of an expression.
4. The RETURN statement can return constant values, such as a text string.
7. The term “actual parameters” refers to the parameters that are listed in the program unit.
8. The term “formal parameters” refers to the arguments that are used when calling or invoking the
program unit.
9. Formal parameters including the RETURN data type cannot include size information.
10. The term “passed by value” means that a pointer to the value in the actual parameter is created instead
of copying the value from the actual parameter to the formal parameter.
11. The term “passed by reference” means that the value is copied from the actual parameter to the formal
parameter.
13. The following is a correct example of the use of the DROP command.
DROP function_name;
MODIFIED TRUE/FALSE
1. A(n) procedure is one type of program unit that is used to accomplish one or more tasks, return none
or many values, and is used only in PL/SQL statements. _________________________
2. A(n) procedure is part of an expression and cannot serve an entire statement. ____________________
ANS: F, function
ANS: F, function
4. In a(n) function, the RETURN statement includes no arguments and is followed with a semicolon.
_________________________
ANS: F, procedure
5. You cannot include data type information when declaring a formal parameter.
________________________
ANS: F, size
6. The term passed by value implies that a pointer to the value in the actual parameter is created instead
of copying the value from the actual parameter to the formal parameter.
_________________________
7. The term passed by reference implies that the value is copied from the actual parameter to the formal
parameter. _________________________
ANS: F, passed by value
8. The default behaviors of value passing can be overridden by using a compiler hint named NOCOPY.
_________________________
9. Functions cannot be used in a(n) CHECK constraint or as a default value of a table column.
_________________________
10. Deleting a program unit can be accomplished by issuing a(n) DEL command.
_________________________
ANS: F, DROP
MULTIPLE CHOICE
b. DECLARE
v_amt1 number(5,2);
v_amt2 number(3,0);
BEGIN
v_amt1 := 32.50;
v_amt2 := ROUND(v_amt1,1);
DBMS_OUTPUT.PUT_LINE(v_ amt2);
END;
c. DECLARE
v_amt1 number(5,2);
v_amt2 number(3,0);
BEGIN
v_amt1 := 32.50;
v_amt2 := ROUND v_amt1, 2;
DBMS_OUTPUT.PUT_LINE(v_ amt2);
END;
d. DECLARE
v_amt1 number(5,2);
v_amt2 number(3,0);
BEGIN
v_amt1 := 32.50;
v_amt2 := ROUND[v_amt1,0];
DBMS_OUTPUT.PUT_LINE(v_ amt2);
END;
4. At least one ____ statement must be included in a function body to instruct which value to return.
a. CREATE c. BEGIN
b. RETURN d. EXCEPTION
ANS: B PTS: 1 REF: 218
a. 1 c. 3
b. 2 d. 4
ANS: C PTS: 1 REF: 219
DECLARE
lv_name_txt VARCHAR2(35);
lv_id_num NUMBER(4) := 25;
lv_first_txt VARCHAR2(15) := 'Scott';
lv_last_txt VARCHAR2(20) := 'David';
BEGIN
lv_name_txt := memfmt1_sf(lv_id_num,lv_first_txt, lv_last_txt);
DBMS_OUTPUT.PUT_LINE(lv_name_txt);
END;
a. procedure c. parameter
b. function d. anonymous block
ANS: D PTS: 1 REF: 217
8. ____ refer to the parameters that are listed in the program unit.
a. Modes c. Procedures
b. Functions d. Formal parameters
ANS: D PTS: 1 REF: 228
9. ____ refer to the arguments that are used when calling or invoking the program unit.
a. Actual parameters c. Formal parameters
b. Functions d. Procedures
ANS: A PTS: 1 REF: 228
10. A good method to handle the size issue when declaring variables that hold values from a database table
is to use the ____ attribute to use the size of the database column.
a. NOCOPY c. << >>
b. %TYPE d. TYPE
ANS: B PTS: 1 REF: 219
11. A(n) ____ is a request a programmer includes within his or her code that asks Oracle to modify the
default processing in some manner.
a. compiler hint c. pass by reference
b. pass by value d. purity level
ANS: A PTS: 1 REF: 230
12. The term ____ is identified with a set of acronyms that indicate the restrictions on using the function.
a. compiler hint c. pass by reference
b. purity level d. pass by value
ANS: B PTS: 1 REF: 232
14. Functions used in SQL statements must meet all of the following requirements, except ____.
a. Must be a stored database object
b. Can use only OUT parameters
c. Return data types must be a database data type
d. Cannot issue ALTER SESSION or ALTER SYSTEM commands
ANS: B PTS: 1 REF: 232
15. All of the following are purity level acronyms, except ____.
a. WNDS c. WNPS
b. RINDS d. RNPS
ANS: B PTS: 1 REF: 232
16. The ____ purity level does not modify database tables.
a. WNDS c. RNPS
b. WNPS d. RNDS
ANS: A PTS: 1 REF: 232
17. Which of the following correctly creates a function that performs an update on the BB_TEST1 table?
a. CREATE OR REPLACE FUNCTION fct_test1_sf (p_num IN NUMBER)
RETURN NUMBER
IS
BEGIN
UPDATE bb_test1
SET col1 = p_num;
RETURN p_num;
END;
18. In the code below, which of the following is the parameter variable?
a. bb_test1 c. p_num
b. col1 d. fct_test1_sf
ANS: C PTS: 1 REF: 218
COMPLETION
ANS: function
ANS: Procedures
3. The task of the ____________________ function is to use the two arguments provided, a numeric
value and the degree of rounding, and return the resulting value.
ANS: ROUND
4. It is considered good form to return only one value from a function and to do so using the
____________________ statement.
ANS: RETURN
PTS: 1 REF: 226
ANS: size
ANS: DROP
ESSAY
ANS:
The main difference between functions and procedures is that a function is part of an expression. It
cannot serve as an entire statement. A procedure, on the other hand, can serve as an entire statement.
ANS:
The term formal parameters refers to the parameters that are listed in the program unit while the term
actual parameters refers to the arguments that are used when calling or invoking a program unit.
3. Discuss the techniques available in PL/SQL for passing values between actual parameters and formal
parameters.
ANS:
PL/SQL uses two techniques for passing values between actual parameters and formal parameters. In
the first method, IN parameter values are passed by reference, which means a pointer to the value in
the actual parameter is created instead of copying the value from the actual parameter to the formal
parameter. In the second, OUT and IN OUT parameters are passed by value in which the value is
copied from the actual to the formal parameter.