Semester 1 Final Exam Oracle PL SQL 3
Semester 1 Final Exam Oracle PL SQL 3
1. You have created a function named NEWFUNC. You now change some of the f
unction code, and try to recreate the function by executing:
CREATE OR REPLACE FUNCTION newfunc .... ;
What happens?
Mark for Review
(1) Points
The command fails because you should execute: CREATE AND REPLACE ....;
Correct
myfunc('Crocodile') := v_var1;
myfunc(v_var1) := 'Crocodile';
myfunc(v_var1, 'Crocodile');
myfunc('Crocodile', v_var1);
Correct
DECLARE
x NUMBER;
BEGIN
x:= add_em(b=4);
END;
(*)
DECLARE
x NUMBER;
BEGIN
x:= add_em(4);
END;
DECLARE
x NUMBER;
BEGIN
x:= add_em(4,5);
END;
DECLARE
x NUMBER;
BEGIN
x:= add_em;
END;
Correct
USER_ERRORS (*)
USER_OBJECTS
USER_DEPENDENCIES
USER_COMPILES
Correct
A function must have at least one IN parameter, while parameters are opt
ional for a procedure.
Correct
They can add business rules to the database and can be reused many times
. (*)
They can be used in a WHERE clause to filter data and thereby increase e
fficiency. (*)
They can do the same job as built-in system functions such as UPPER and
ROUND.
Correct
The data type for the tax variable does not match the data type for sala
ry
True (*)
False
Correct
USER_PROCEDURES
USER_OBJECTS
USER_SOURCE (*)
USER_SUBPROGRAMS
Correct
11. You want to see the names, modes and data types of the formal parameter
s of function MY_FUNC in your schema. How can you do this? (Choose two) Mark for
Review
(1) Points
(Choose all correct answers)
Query USER_PARAMETERS
CHILD1 ends abruptly. PARENT handles the exception and then ends. CHILD2
does not execute. (*)
CHILD1 ends abruptly, PARENT handles the exception, then CHILD2 executes
.
CHILD1 ends abruptly, PARENT also ends abruptly and returns an unhandled
exception.
PARENT does not compile because you cannot use NULL; in an exception han
dler.
Correct
EXECUTE on REYHAN.PROC1
SELECT on TOM.EMPLOYEES
None of the above. The procedure will fail to compile because REYHAN doe
s not have SELECT privilege on TOM.EMPLOYEES.
Correct
Correct
15. User BOB creates procedure MYPROC using the default Defi
ner's Rights. BOB then executes:
GRANT EXECUTE ON bob.myproc TO ted;
When TED invokes BOB.MYPROC, whose privileges are checked?
Mark for Review
(1) Points
TED's privileges
PUBLIC's privileges
SYSTEM's privileges
ORACLE's privileges
Correct
Section 8
(Answer all questions in this section)
16. Which of the following are characteristics of PL/SQL su
bprograms but not of anonymous PL/SQL blocks? (Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
Correct
The statement will fail because the last line of code should be END emp_
proc;
The statement will fail because you cannot declare variables such as v_s
alary inside a procedure.
The statement will fail because the procedure does not have any paramete
rs.
Correct
F,C,A,B,E,D
F,B,D,A,E,C (*)
E,D,F,C,A,B
F,B,D,E,A,C
F,B,C,D,E,A
Correct
False
Correct
Twice
Four times
None (*)
Eight times
Once
Correct
21. Which of the following are characteristics of PL/SQL stored procedures?
(Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
Correct
22. Suppose you set up a parameter with an explicit OUT mod
e. What is true about that parameter? Mark for Review
(1) Points
It acts like a constant (its value cannot be changed inside the subprogr
am).
Correct
It acts like a constant (its value cannot be changed inside the subprogr
am). (*)
myproc(40);
Correct
Positional (*)
Named
Defaulted
Correct
BEGIN
EXECUTE double_it(20);
END;
BEGIN
SELECT double_it(20)
FROM DUAL;
END;
DECLARE
v_result NUMBER(6);
BEGIN
v_result := double_it(20);
END;
DECLARE
v_result NUMBER(6) := 20;
BEGIN
double_it(v_result);
END; (*)
BEGIN
double_it(20);
END;
Correct
True
False (*)
Correct
It passes a value into the procedure when the procedure is invoked. (*)
Correct
(p_param IN VARCHAR2)
(p_param VARCHAR2)
(p_param employees.last_name%TYPE)
Correct
Correct
31. An INDEX BY TABLE must have a primary key Mark for Review
(1) Points
True (*)
False
Correct
True (*)
False
Section 7
(Answer all questions in this section)
33. Department-id 99 does not exist. What will be displayed
when the following code is executed?
DECLARE
v_deptname departments.department_name%TYPE;
BEGIN
SELECT department_name INTO v_deptname
FROM departments WHERE department_id = 99;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RAISE_APPLICATION_ERROR(-20201,'Department does not exist');
END;
Mark for Review
(1) Points
Correct
RAISE_APPLICATION_ERROR('Error Raised',-22001);
RAISE_APPLICATION_ERROR(-22001,'Error Raised');
RAISE_APPLICATION_ERROR('Error Raised',-20257);
Correct
A and B
B and C (*)
A and C
Correct
True
False (*)
The code will execute successfully and 'Outer Raised' will be displayed.
The code will fail to compile because e_inner_excep was declared but nev
er RAISEd.
Correct
Correct
True (*)
False
Correct
A
C
D
A
D
(*)
A
B
D
Correct
41. Examine the following code fragment. At Line A, you want to raise an ex
ception if the fetched salary value is greater than 30000. How can you do this?
DECLARE
v_salary employees.salary%TYPE;
BEGIN
SELECT salary INTO v_salary FROM employees
WHERE employee_id = 100;
IF v_salary > 30000 THEN
-- Line A
END IF;
...
Mark for Review
(1) Points
Correct
WHEN CURSOR_NOT_OPEN
WHEN NO_DATA_FOUND
WHEN INVALID_FETCH
Correct
User-defined errors
All errors
Correct
OTHERS
DECLARE
e_sal_excep EXCEPTION;
PRAGMA EXCEPTION_INIT(-02290,e_sal_excep);
DECLARE
PRAGMA EXCEPTION_INIT(e_sal_excep,-02290);
e_sal_excep EXCEPTION;
DECLARE
e_sal_excep EXCEPTION;
PRAGMA EXCEPTION_INIT(e_sal_excep,-02290);
(*)
DECLARE
e_sal_excep EXCEPTION;
PRAGMA_EXCEPTION_INIT(e_sal_exception,-02290);
DECLARE
e_sal_excep EXCEPTION;
PRAGMA EXCEPTION_INIT(e_sal_excep,02290);
Correct
True (*)
False
Correct
Any other kind of exception that can occur within the block
Correct
Correct
50. Examine the following code. Why does the exception hand
ler not follow good practice guidelines?
DECLARE
v_salary employees.salary%TYPE;
BEGIN
SELECT salary INTO v_salary FROM employees
WHERE employee_id = 999;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('An error occurred');
END;
Mark for Review
(1) Points
The exception handler should test for the named exception NO_DATA_FOUND.
(*)
Correct