View the Exhibit and examine the structure of the EMP table.
You want to create two procedures using the overloading feature to search for employee details based on either the employee name or employee number. Which two rules should you apply to ensure that the overloading feature is used successfully? (Choose two.)
A.
The procedures can be either stand-alone or packaged.
B.
The procedures should be created only as packaged subprograms
C.
The procedures should be created only as stand-alone subprograms
D.
Each subprogram’s formal parameters should differ in both name and data type.
E.
The formal parameters of each subprogram should differ in data type but can use the same names.
Correct answers: B E
must be a,e, test it:
CREATE OR REPLACE PROCEDURE GET_CHAR (V_TEXT IN VARCHAR2)
as
BEGIN
NULL;
END;
/
CREATE OR REPLACE PROCEDURE GET_CHAR (V_TEXT IN number)
as
BEGIN
NULL;
END;
/
But again, the question is bad. If my knowledge of english is correct the first answer means: you can use both of them, but you dont have to.
answer b, c: “the procedures should..” means, it can be in packaged subprograms, but it does not have to. Its more like an advice.
B and E is correct
“….that the overloading feature is used successfully?”
You cannot overload procedure in schema scope, therefore A is not correct.
http://docs.oracle.com/cd/B10500_01/appdev.920/a96624/08_subs.htm#12353
Only local or packaged subprograms, or type methods, can be overloaded. Therefore, you cannot overload standalone subprograms. Also, you cannot overload two subprograms if their formal parameters differ only in name or parameter mode.
http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/subprograms.htm#LNPLS00807
PL/SQL lets you overload nested subprograms, package subprograms, and type methods.
Kuki – the second procedure replaces the first in your example. Hence I am sure that B and E are correct
you used “create OR REPLACE”
so the second definition of get_char drops the first.
try
drop PROCEDURE GET_CHAR;
— how could the drop above statement know which one, if there could be more than one
procedure with the same name in the schema ?
CREATE PROCEDURE GET_CHAR (V_TEXT IN VARCHAR2)
as
BEGIN
NULL;
END;
/
CREATE PROCEDURE GET_CHAR (V_TEXT IN number)
as
BEGIN
NULL;
END;
/
B,E
B,E
ooooo :O
B y E