Documente Academic
Documente Profesional
Documente Cultură
True (*)
False
Correct Correct
True
False (*)
Correct Correct
Test your code with different combinations of data to see what potential
errors can happen. (*)
Include a WHEN OTHERS handler as the first handler in the exception sect
ion.
Allow exceptions to propagate back to the calling environment.
Correct Correct
The exception handler should test for the named exception NO_DATA_FOUND.
(*)
Correct Correct
No employees found
The block will fail because you cannot explicitly RAISE a predefined Ora
cle Server error such as NO_DATA_FOUND
Correct Correct
FLAG exception_name;
RAISE(error_number, exception_name);
Correct Correct
Message 1
Message 3
Message 1
Message 2
Message 1
Message 3
Message 4
Message 1
Message 4
(*)
Correct Correct
Test for WHEN OTHERS in the exception section, because WHEN OTHERS traps
all exceptions.
Has a standard Oracle error number but must be named by the PL/SQL progr
ammer
Has a standard Oracle error number and a standard name which can be refe
renced in the EXCEPTION section (*)
Correct Correct
Page 1 of 5 Next Summary
Vynechat navigacné prvky k obsahu stránky
Test: Semester 1 Final Exam
Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Section 7
11. Examine the following code. What message or messages wil
l be displayed when this code is executed?
DECLARE
v_last_name employees.last_name%TYPE;
v_number NUMBER := 27;
BEGIN
v_number := v_number / 0;
SELECT last_name INTO v_last_name FROM employees
WHERE employee_id = 999;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No rows were found');
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Attempt to divide by zero');
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('An error occurred');
END;
(1) Points
An error occurred
TOO_MANY_ROWS (*)
NO_DATA_FOUND (*)
OTHERS
ZERO_DIVIDE (*)
E_INSERT_EXCEP
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 Correct
OTHERS
A SELECT statement returns more than one row.
True (*)
False
Correct Correct
16. The following code does not violate any constraints and
will not raise an ORA-02292 error. What will happen when the code is executed?
BEGIN
DECLARE
e_constraint_violation EXCEPTION;
PRAGMA EXCEPTION_INIT(e_constraint_violation, -2292);
BEGIN
DBMS_OUTPUT.PUT_LINE('Inner block message');
END;
EXCEPTION
WHEN e_constraint_violation THEN
DBMS_OUTPUT.PUT_LINE('Outer block message');
END;
(1) Points
The code will fail because the exception is declared in the inner block
but is referenced in the outer block. (*)
The code will fail because line 4 should read: PRAGMA EXCEPTION_INIT(-22
92, e_constraint_violation);
Correct Correct
The code will propagate the e_outer_excep back to the calling environmen
t.
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
A
C
D
A
D
(*)
A
B
D
Correct Correct
Section 8
19. Which of the following statements about actual parameter
s is NOT true? (1) Points
Correct Correct
20. Examine the following procedure:
CREATE OR REPLACE PROCEDURE smallproc
(p_param IN NUMBER)
IS
BEGIN ....
The procedure is invoked by:
DECLARE
v_param NUMBER := 20;
BEGIN
smallproc(v_param);
END;
Which of the following statements is true?
(1) Points
Correct Correct
The procedure cannot be modified. Once a procedure has been created, the
number of parameters cannot be changed.
It passes a value into the procedure when the procedure is invoked. (*)
Correct Correct
defproc;
Positionally
Named (*)
Defaulted
It acts like a constant (its value cannot be changed inside the subprogr
am).
IN (*)
OUT
NUMBER
VARIABLE
CONSTANT
Correct Correct
True (*)
False
Correct 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
True
False (*)
Correct Correct
True (*)
False
Correct Correct
Section 9
34. The following code shows the dependencies between three
procedures:
CREATE PROCEDURE parent
IS BEGIN
child1;
child2;
END parent;
You now try to execute:
DROP PROCEDURE child2;
What happens?
(1) Points
CHILD2 is dropped successfully. PARENT and CHILD1 are both marked INVALI
D.
CHILD1 ends abruptly, PARENT handles the exception successfully and ends
. CHILD2 does not execute.
CHILD1 ends abruptly, then PARENT also ends abruptly with an unhandled e
xception.
PARENT fails to compile because you cannot have the same exception handl
er in two separate subprograms.
Correct Correct
36. You want to see the names, modes and data types of the f
ormal parameters of function MY_FUNC in your schema. How can you do this? (Choos
e two) (1) Points
(Choose all correct answers)
Query USER_PARAMETERS
Query USER_SOURCE (*)
Query USER_FUNCTIONS
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.
The data type for the tax variable does not match the data type for sala
ry
True (*)
False
Correct Correct
In a WHERE clause.
A procedure can have default values for parameters, while a function can
not.
Correct Correct
True
False (*)
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;
A function must have at least one IN parameter, while parameters are opt
ional for a procedure.
You must declare the type of the RETURN before the IS. (*)
The body of the function must contain at least one executable statement
(as well as RETURN).
Section 6
49. You can store a whole record in a single variable using
%ROWTYPE or by creating your own record structure as a type and then declaring a
variable of that type. (1) Points
True (*)
False
Correct Correct
INDEX BY VIEW