Deck 6: Functions

Full screen (f)
exit full mode
Question
The term "actual parameters" refers to the parameters that are listed in the program unit.
Use Space or
up arrow
down arrow
to flip the card.
Question
You cannot include data type information when declaring a formal parameter. ________________________
Question
In a(n) function, the RETURN statement includes no arguments and is followed with a semicolon. _________________________
Question
The term "passed by reference" means that the value is copied from the actual parameter to the formal parameter.
Question
The RETURN statement can return constant values, such as a text string.
Question
A(n) procedure cannot be invoked in a standalone fashion. _________________________
Question
The term "formal parameters" refers to the arguments that are used when calling or invoking the program unit.
Question
A(n) procedure is part of an expression and cannot serve an entire statement. ____________________
Question
You can include multiple RETURN statements in the body of a function.
Question
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.
Question
The following is a correct example of the use of the DROP command.
DROP function_name;
Question
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. _________________________
Question
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. _________________________
Question
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.
Question
It is possible to reference a data dictionary to determine what code is contained in a program unit.
Question
The main difference between functions and procedures is that a function is part of an expression.
Question
Formal parameters including the RETURN data type cannot include size information.
Question
The term passed by reference implies that the value is copied from the actual parameter to the formal parameter. _________________________
Question
Procedures can be used in SQL statements.
Question
The RETURN statement in a function is used to control the flow of execution.
Question
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
Question
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
B) %TYPE
C) << >>
D) TYPE
Question
At least one ____ statement must be included in a function body to instruct which value to return.

A) CREATE
B) RETURN
C) BEGIN
D) EXCEPTION
Question
Functions cannot be used in a(n) CHECK constraint or as a default value of a table column. _________________________
Question
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
B) pass by value
C) pass by reference
D) purity level
Question
Which of the following statements is True?

A) After IN OUT parameters are included in functions, the function can no longer be used in SQL statements.
B) After OUT parameters are included in functions, the function can no longer be used in SQL statements.
C) After INOUT parameters are included in functions, the function can no longer be used in SQL statements.
D) After IN parameters are included in functions, the function can no longer be used in SQL statements.
Question
How many input values does the following code require?
CREATE OR REPLACE FUNCTION memfmt1_sf
(p_id IN NUMBER,
P_first IN VARCHAR2,
P_last IN VARCHAR2)
RETURN VARCHAR2
IS
Lv_mem_txt VARCHAR2(35);
BEGIN
Lv_mem_txt := 'Member ' ||p_id|| ' - ' ||p_first|| ' ' ||p_last;
RETURN lv_mem_txt;
END;

A) 1
B) 2
C) 3
D) 4
Question
The default behaviors of value passing can be overridden by using a compiler hint named NOCOPY. _________________________
Question
Which of the following statements is incorrect?

A) A procedure can serve as an entire statement.
B) A function is part of an expression.
C) Procedures can be used in SQL statements.
D) A function cannot serve as an entire statement.
Question
All of the following represent restrictions on functions, except ____.

A) Functions cannot modify any tables in Oracle8 and prior versions.
B) Functions cannot be used in a CHECK constraint or as a default value of a table column.
C) If used in a local operation, no reading or writing of packaged variables is allowed.
D) If used in a SELECT, VALUES, or SET clause, the function can write values to packaged variables; otherwise, it is not allowed.
Question
____ refer to the parameters that are listed in the program unit.

A) Modes
B) Functions
C) Procedures
D) Formal parameters
Question
Which of the following code fragments would not raise an error?

A) CREATE OR REPLACE FUNCTION ship_calc(p_qty IN NUMBER)
IS
Lv_ship_num NUMBER(5,2);
BEGIN
IF p_qty > 10 THEN
Lv_ship_num := 11.00;
ELSE
Lv_ship_num := 5.00;
END IF;
RETURN lv_ship_num;
END;
B) CREATE OR REPLACE ship_calc(p_qty)
RETURN NUMBER
IS
Lv_ship_num NUMBER(5,2);
BEGIN
IF p_qty > 10 THEN
Lv_ship_num := 11.00;
ELSE
Lv_ship_num := 5.00;
ENDIF;
RETURN lv_ship_num;
END;
C) CREATE OR REPLACE FUNCTION ship_calc(p_qty IN NUMBER)
RETURN NUMBER
IS
Lv_ship_num NUMBER(5,2);
BEGIN
IF p_qty > 10 THEN
Lv_ship_num := 11.00;
ELSE
Lv_ship_num := 5.00;
END IF;
RETURN lv_ship_num;
END;
D) CREATE OR REPLACE FUNCTION ship_calc(p_qty IN NUMBER)
RETURN NUMBER
BEGIN
IF p_qty > 10 THEN
Lv_ship_num := 11.00;
ELSE
Lv_ship_num := 5.00;
END IF;
RETURN lv_ship_num;
END;
Question
The ____ purity level does not modify database tables.

A) WNDS
B) WNPS
C) RNPS
D) RNDS
Question
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;
B) 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;
C) CREATE OR REPLACE FUNCTION fct_test1_sf (p_num)
RETURN NUMBER
IS
BEGIN
UPDATE bb_test1
RETURN p_num;
END;
D) CREATE OR REPLACE FUNCTION fct_test1_sf (p_num IN NUMBER(6))
RETURN NUMBER
IS
BEGIN
UPDATE bb_test1
SET col1 = p_num;
RETURN p_num
END
Question
The term ____ is identified with a set of acronyms that indicate the restrictions on using the function.

A) compiler hint
B) purity level
C) pass by reference
D) pass by value
Question
____ refer to the arguments that are used when calling or invoking the program unit.

A) Actual parameters
B) Functions
C) Formal parameters
D) Procedures
Question
Deleting a program unit can be accomplished by issuing a(n) DEL command. _________________________
Question
The following code is an example of a(n) ____.
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
B) function
C) parameter
D) anonymous block
Question
Which of the following code fragments would not raise an error?

A) DECLARE
V_amt1 number(5,2);
V_amt2 number(3,0);
BEGIN
V_amt1 := 32.50;
V_amt2 := ROUND(v_amt1)
DBMS_OUTPUT.PUT_LINE(v_ amt2);
END;
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;
Question
All of the following are purity level acronyms, except ____.

A) WNDS
B) RINDS
C) WNPS
D) RNPS
Question
What are the main differences between a function and a procedure?
Question
The ____ command is used to view parameter information.

A) DROP
B) SET
C) DESC
D) OUT
Question
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.
Question
Discuss the techniques available in PL/SQL for passing values between actual parameters and formal parameters.
Question
What are formal and actual parameters?
Question
A(n) ____________________ cannot serve as an entire statement.
Question
____________________ cannot be used in SQL statements.
Question
You cannot include ____________________ information when declaring a formal parameter.
Question
In the code below, which of the following is the parameter variable?
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;

A) bb_test1
B) col1
C) p_num
D) fct_test1_sf
Question
Deleting a program unit can be accomplished by issuing a(n) ____________________ command.
Question
It is considered good form to return only one value from a function and to do so using the ____________________ statement.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/51
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 6: Functions
1
The term "actual parameters" refers to the parameters that are listed in the program unit.
False
2
You cannot include data type information when declaring a formal parameter. ________________________
False, size
3
In a(n) function, the RETURN statement includes no arguments and is followed with a semicolon. _________________________
False, procedure
4
The term "passed by reference" means that the value is copied from the actual parameter to the formal parameter.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
5
The RETURN statement can return constant values, such as a text string.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
6
A(n) procedure cannot be invoked in a standalone fashion. _________________________
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
7
The term "formal parameters" refers to the arguments that are used when calling or invoking the program unit.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
8
A(n) procedure is part of an expression and cannot serve an entire statement. ____________________
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
9
You can include multiple RETURN statements in the body of a function.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
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.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
11
The following is a correct example of the use of the DROP command.
DROP function_name;
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
12
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. _________________________
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
13
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. _________________________
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
14
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.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
15
It is possible to reference a data dictionary to determine what code is contained in a program unit.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
16
The main difference between functions and procedures is that a function is part of an expression.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
17
Formal parameters including the RETURN data type cannot include size information.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
18
The term passed by reference implies that the value is copied from the actual parameter to the formal parameter. _________________________
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
19
Procedures can be used in SQL statements.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
20
The RETURN statement in a function is used to control the flow of execution.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
21
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
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
22
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
B) %TYPE
C) << >>
D) TYPE
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
23
At least one ____ statement must be included in a function body to instruct which value to return.

A) CREATE
B) RETURN
C) BEGIN
D) EXCEPTION
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
24
Functions cannot be used in a(n) CHECK constraint or as a default value of a table column. _________________________
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
25
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
B) pass by value
C) pass by reference
D) purity level
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
26
Which of the following statements is True?

A) After IN OUT parameters are included in functions, the function can no longer be used in SQL statements.
B) After OUT parameters are included in functions, the function can no longer be used in SQL statements.
C) After INOUT parameters are included in functions, the function can no longer be used in SQL statements.
D) After IN parameters are included in functions, the function can no longer be used in SQL statements.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
27
How many input values does the following code require?
CREATE OR REPLACE FUNCTION memfmt1_sf
(p_id IN NUMBER,
P_first IN VARCHAR2,
P_last IN VARCHAR2)
RETURN VARCHAR2
IS
Lv_mem_txt VARCHAR2(35);
BEGIN
Lv_mem_txt := 'Member ' ||p_id|| ' - ' ||p_first|| ' ' ||p_last;
RETURN lv_mem_txt;
END;

A) 1
B) 2
C) 3
D) 4
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
28
The default behaviors of value passing can be overridden by using a compiler hint named NOCOPY. _________________________
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
29
Which of the following statements is incorrect?

A) A procedure can serve as an entire statement.
B) A function is part of an expression.
C) Procedures can be used in SQL statements.
D) A function cannot serve as an entire statement.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
30
All of the following represent restrictions on functions, except ____.

A) Functions cannot modify any tables in Oracle8 and prior versions.
B) Functions cannot be used in a CHECK constraint or as a default value of a table column.
C) If used in a local operation, no reading or writing of packaged variables is allowed.
D) If used in a SELECT, VALUES, or SET clause, the function can write values to packaged variables; otherwise, it is not allowed.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
31
____ refer to the parameters that are listed in the program unit.

A) Modes
B) Functions
C) Procedures
D) Formal parameters
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
32
Which of the following code fragments would not raise an error?

A) CREATE OR REPLACE FUNCTION ship_calc(p_qty IN NUMBER)
IS
Lv_ship_num NUMBER(5,2);
BEGIN
IF p_qty > 10 THEN
Lv_ship_num := 11.00;
ELSE
Lv_ship_num := 5.00;
END IF;
RETURN lv_ship_num;
END;
B) CREATE OR REPLACE ship_calc(p_qty)
RETURN NUMBER
IS
Lv_ship_num NUMBER(5,2);
BEGIN
IF p_qty > 10 THEN
Lv_ship_num := 11.00;
ELSE
Lv_ship_num := 5.00;
ENDIF;
RETURN lv_ship_num;
END;
C) CREATE OR REPLACE FUNCTION ship_calc(p_qty IN NUMBER)
RETURN NUMBER
IS
Lv_ship_num NUMBER(5,2);
BEGIN
IF p_qty > 10 THEN
Lv_ship_num := 11.00;
ELSE
Lv_ship_num := 5.00;
END IF;
RETURN lv_ship_num;
END;
D) CREATE OR REPLACE FUNCTION ship_calc(p_qty IN NUMBER)
RETURN NUMBER
BEGIN
IF p_qty > 10 THEN
Lv_ship_num := 11.00;
ELSE
Lv_ship_num := 5.00;
END IF;
RETURN lv_ship_num;
END;
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
33
The ____ purity level does not modify database tables.

A) WNDS
B) WNPS
C) RNPS
D) RNDS
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
34
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;
B) 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;
C) CREATE OR REPLACE FUNCTION fct_test1_sf (p_num)
RETURN NUMBER
IS
BEGIN
UPDATE bb_test1
RETURN p_num;
END;
D) CREATE OR REPLACE FUNCTION fct_test1_sf (p_num IN NUMBER(6))
RETURN NUMBER
IS
BEGIN
UPDATE bb_test1
SET col1 = p_num;
RETURN p_num
END
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
35
The term ____ is identified with a set of acronyms that indicate the restrictions on using the function.

A) compiler hint
B) purity level
C) pass by reference
D) pass by value
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
36
____ refer to the arguments that are used when calling or invoking the program unit.

A) Actual parameters
B) Functions
C) Formal parameters
D) Procedures
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
37
Deleting a program unit can be accomplished by issuing a(n) DEL command. _________________________
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
38
The following code is an example of a(n) ____.
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
B) function
C) parameter
D) anonymous block
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
39
Which of the following code fragments would not raise an error?

A) DECLARE
V_amt1 number(5,2);
V_amt2 number(3,0);
BEGIN
V_amt1 := 32.50;
V_amt2 := ROUND(v_amt1)
DBMS_OUTPUT.PUT_LINE(v_ amt2);
END;
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;
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
40
All of the following are purity level acronyms, except ____.

A) WNDS
B) RINDS
C) WNPS
D) RNPS
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
41
What are the main differences between a function and a procedure?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
42
The ____ command is used to view parameter information.

A) DROP
B) SET
C) DESC
D) OUT
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
43
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.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
44
Discuss the techniques available in PL/SQL for passing values between actual parameters and formal parameters.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
45
What are formal and actual parameters?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
46
A(n) ____________________ cannot serve as an entire statement.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
47
____________________ cannot be used in SQL statements.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
48
You cannot include ____________________ information when declaring a formal parameter.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
49
In the code below, which of the following is the parameter variable?
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;

A) bb_test1
B) col1
C) p_num
D) fct_test1_sf
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
50
Deleting a program unit can be accomplished by issuing a(n) ____________________ command.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
51
It is considered good form to return only one value from a function and to do so using the ____________________ statement.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 51 flashcards in this deck.