Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
2. Which of the following is a good reason to use two cursors in a single PL/SQL block?
It is the only way to declare a cursor with a parameter.
When two tables are related to each other (often by a foreign key) and we want to produce a multilevel
report using data from both tables. (*)
To speed up the execution of the PL/SQL block.
To allow one cursor to be opened twice at the same time.
To allow rows to be locked as they are FETCHed.
None of these.
The first 6 fetched rows will be updated.
No rows will be updated because you locked the rows when the cursor was opened.
15. Assume that you have declared a cursor called C_EMP. Which of the following statements about C_EMP is correct?
(Choose two.)
You can use c_emp%NOTFOUND to exit a loop. (*)
You can fetch rows when c_emp%ISOPEN evaluates to FALSE.
You can use c_emp%FOUND after the cursor is closed.
You can use c_emp%ROWCOUNT to return the number of rows returned by the cursor so far. (*)
16. You can reference explicit cursor attributes directly in a SQL statement. True or False?
True
False (*)
17. Which of the following statements about user-defined PL/SQL records is NOT true?
It can be used as an OUT parameter in a package procedure.
It can be a component of another PL/SQL record.
It can be defined as NOT NULL.
It must contain one or more components, but all the components must have scalar datatypes. (*)
It is not the same as a row in a database table.
20. 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;
'Inner block message' will be displayed.
The code will fail because line 4 should read: PRAGMA EXCEPTION_INIT(-2292, e_constraint_violation);
The code will fail because the exception is declared in the inner block but is referenced in the outer
block. (*)
'Outer block message' will be displayed.
21. Which of these exceptions can be handled by an EXCEPTION section in a PL/SQL block?
An attempt is made to divide by zero
Any other kind of exception that can occur within the block
A SELECT statement returns no rows
None of these.
All of these. (*)
22. While a PL/SQL block is executing, more than one exception can occur at the same time. True or False?
TRUE
FALSE (*)
23. Which of the following are good practice guidelines for exception handling? (Choose three.)
Test your code with different combinations of data to see what potential errors can happen. (*)
Handle specific named exceptions where possible, instead of relying on WHEN OTHERS. (*)
Allow exceptions to propagate back to the calling environment.
Use an exception handler whenever there is any possibility of an error occurring. (*)
Include a WHEN OTHERS handler as the first handler in the exception section.
27. An attempt to insert a null value into a NOT NULL table column raises an ORA-01400 exception. How can you code an
exception handler to trap this exception?
Declare a variable e_null_excep of type EXCEPTION, associate it with ORA-01400 using a PRAGMA
directive, and test for WHEN e_null_excep in the exception section. (*)
Declare a variable e_null_excep of type VARCHAR2, associate it with ORA-01400 using a PRAGMA
directive, and test for WHEN e_null_excep in the exception section.
Declare a variable as follows: e_null_excep EXCEPTION := -01400; Then test for WHEN e_null_excep in
the exception section.
Test for WHEN ORA-1400 in the exception section.
28. A PL/SQL block executes and an Oracle Server exception is raised. Which of the following contains the text message
associated with the exception?
SQL_MESSAGE_TEXT
SQL%MESSAGE
SQLERRM (*)
SQLCODE
30. Which of the following can NOT be used as the datatype of a procedure parameter?
A PLSQL record defined using %ROWTYPE
A non-SQL datatype such as BOOLEAN
A large object datatype such as CLOB
The name of another procedure (*)
31. Parameters are a special form of a variable, whose input values are initialized by the calling environment when the
subprogram is called, and whose output values are returned to the calling environment when the subprogram returns
control to the caller.
True (*)
False
32. What will happen when the following procedure is called as format_phone (8005551234)?
CREATE OR REPLACE PROCEDURE format_phone
(p_phone_no IN OUT VARCHAR2) IS
BEGIN
p_phone_no := SUBSTR(p_phone_no,1,3) ||
'.' || SUBSTR(p_phone_no,4,3) ||
'.' || SUBSTR(p_phone_no,7);
END format_phone;
The procedure does not execute because the input variable is not properly declared.
The phone number 800.555.1234 is placed into the p_phone_no variable. (*)
The phone number (800) 555-1234 is printed to the screen.
The phone number 800.555.1234 is printed to the screen.
36. Which of the following are benefits of using PL/SQL subprograms rather than anonymous blocks? (Choose three.)
38. A function must have at least one IN parameter, and must return exactly one value.
True
False (*)
40. You need to remove procedure BADPROC from your schema. What is the correct syntax to do this?
DELETE PROCEDURE badproc;
DROP PROCEDURE badproc; (*)
ALTER PROCEDURE badproc DISABLE;
DROP PROGRAM badproc;
41. The database administrator has granted the DROP ANY PROCEDURE privilege to user KIM. This allows Kim to remove
other users' procedures and functions from the database. How would Kim now drop function GET_EMP, which is owned
by user MEHMET?
DROP PROGRAM mehmet.get_emp
DROP FUNCTION mehmet.get_emp (*)
DROP FUNCTION get_emp FROM mehmet
DROP PROCEDURE mehmet.get_emp
None of these
43. Your schema contains two procedures named CHILD1 and CHILD2. You now create a third procedure by executing:
CREATE OR REPLACE PROCEDURE parent IS
BEGIN
child1;
child2;
END;
You now want user JOE to be able to invoke PARENT. Which of the following gives JOE the privileges he needs, but no
unnecessary privileges?
GRANT EXECUTE ON parent TO joe WITH ADMIN OPTION;
GRANT EXECUTE ON parent TO joe; (*)
GRANT EXECUTE ON * TO joe;
GRANT EXECUTE ON parent TO joe; GRANT EXECUTE ON child1 TO joe; GRANT EXECUTE ON child2 TO
joe;
GRANT EXECUTE ON parent, child1, child2 TO joe;
45. Which of the following is a legal location for a function call in a SQL statement? (Choose 3)
The ORDER BY and GROUP BY clauses of a query (*)
VALUES clause of an INSERT statement (*)
WHERE clause in a DELETE statement (*)
CREATE TABLE statement
48. You want to display the names of all tables in your schema, but you have forgotten which Dictionary view to query.
Which of the following will remind you of the name of the correct Dictionary view?
SELECT *
FROM DICTIONARY
WHERE table_name LIKE 'user%table%';
HELP DICTIONARY
SELECT *
FROM DICTIONARY
WHERE table_name LIKE 'USER%TAB%'; (*)
SELECT *
FROM DICTIONARY
WHERE table_name LIKE 'DBA%TABLE%';
SELECT *
FROM USER_OBJECTS
WHERE table_name LIKE '%TABLE%';
49. Procedure GET_EMPS includes a SELECT…FROM EMPLOYEES. The procedure was created using Invoker's Rights.
Which of the following statements are true? (Choose three.)
The user who executes the procedure does not need any privileges.
The user who executes the procedure needs EXECUTE privilege on the procedure. (*)
The user who executes the procedure needs SELECT privilege on EMPLOYEES. (*)
The creator of the procedure needs SELECT privilege on EMPLOYEES. (*)
50. How do you specify that you want a procedure MYPROCA to use "Definer's Rights"?
CREATE OR REPLACE PROCEDURE myproca AUTHID CURRENT_USER IS...
Definer's Rights are the default, therefore no extra code or commands are needed. (*)
ALTER PROCEDURE myproca TO DEFINER;
CREATE OR REPLACE PROCEDURE myproca AUTHID OWNER IS...
GRANT DEFINER TO myprocA;