0% found this document useful (0 votes)
112 views6 pages

Quiz 12

This document contains 15 multiple choice questions about SQL and PL/SQL. Question 2 asks what will happen when a procedure that uses dynamic SQL to drop all views in the user's schema is invoked. The correct answer is that all views in the user's schema will be dropped. Question 3 is false - more than one call to DBMS_SQL is needed to drop a table. Question 5 is true - SQL statements in a procedure are parsed when the procedure is compiled.

Uploaded by

Andriy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views6 pages

Quiz 12

This document contains 15 multiple choice questions about SQL and PL/SQL. Question 2 asks what will happen when a procedure that uses dynamic SQL to drop all views in the user's schema is invoked. The correct answer is that all views in the user's schema will be dropped. Question 3 is false - more than one call to DBMS_SQL is needed to drop a table. Question 5 is true - SQL statements in a procedure are parsed when the procedure is compiled.

Uploaded by

Andriy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

 Which of the following SQL statements can be included in a PL/SQL block


only by using Dynamic SQL? (Choose two.)
Mark for Review

(1) Points
SELECT ..... FOR UPDATE NOWAIT
GRANT (*)
SAVEPOINT
ALTER (*)
DELETE
Correct

2. Examine the following code:


CREATE OR REPLACE PROCEDURE myproc IS
    CURSOR c_curs IS SELECT view_name FROM user_views;
BEGIN
    FOR v_curs_rec IN c_curs LOOP
       EXECUTE IMMEDIATE 'DROP VIEW ' || v_curs_rec.view_name;
    END LOOP;
END;

What will happen when this procedure is invoked?

Mark for Review

(1) Points
All views in the user's schema will be dropped. (*)
The procedure will raise an exception because one of the views is a complex
view.
The procedure will raise an exception because Dynamic SQL can drop tables
but cannot drop views.
The procedure will not compile successfully because the syntax of EXECUTE
IMMEDIATE is incorrect.
Correct

3. Only one call to DBMS_SQL is needed in order to drop a table. True or


False?
Mark for Review

(1) Points
True
False (*)
Correct

4. A programmer wants to code a procedure which will create a table with a
single column. The datatype of the column will be chosen by the user who
invokes the procedure. The programmer writes the following code:
CREATE OR REPLACE PROCEDURE create_tab
    (p_col_datatype IN VARCHAR2) IS
BEGIN
    CREATE TABLE newtab (only_col p_col_datatype);
END;

Why will this procedure not compile successfully?

Mark for Review

(1) Points
Because you cannot create a table inside a procedure
Because the invoking user may not have CREATE TABLE privilege
Because when the procedure is compiled, Oracle cannot check if the
parameter value passed into the procedure is a valid column datatype (*)
Because table NEWTAB may already exist
None of the above; the procedure will compile successfully.
Correct

5. When SQL statements are included within a procedure, the statements


are parsed when the procedure is compiled. True or False?
Mark for Review

(1) Points
True (*)
False
Correct
6. What happens when a SQL statement is parsed? (Choose three.)
Mark for Review

(1) Points
The statement is executed.
The user's required privileges are checked. (*)
Oracle queries the Data Dictionary to make sure that the tables referenced
in the SQL statement exist. (*)
The results of the statement are returned to the user.
The syntax of the statement is checked. (*)
Correct

7. A public packaged procedure contains the following SQL statement:


UPDATE employees
SET salary = salary * 1.1;
When is this SQL statement parsed?
Mark for Review

(1) Points
When the package is loaded into memory
When the package specification is created
When the package header is loaded into memory
When the package body is created (*)
Only the first time the procedure is executed
Correct

8. The following procedure compiles successfully. True or False?


CREATE OR REPLACE PACKAGE emp_pkg IS
  TYPE t_emp IS TABLE OF employees%ROWTYPE
    INDEX BY BINARY_INTEGER;
  PROCEDURE emp_proc
    (p_small_arg IN NUMBER, p_big_arg NOCOPY OUT t_emp);
...
END emp_pkg;

Mark for Review

(1) Points
True
False (*)
Correct

9. What is the main purpose for using the RETURNING clause?


Mark for Review

(1) Points
Improve performance by making one call to the SQL engine (*)
Improve performance by returning a single value
Return more readily any exceptions that are raised by the statement
Improve performance by minimizing the number of statements
Correct

10. FORALL can only be used with the INSERT statement. True or False?
Mark for Review

(1) Points
True
False (*)
Correct
Previous
11. In the following example, where do you place the phrase BULK
COLLECT?
...
BEGIN
  SELECT -- Position A
     salary -- Position B
     INTO v_saltab -- Position C
     FROM employees WHERE department_id = 20 ORDER BY salary
     -- Position D
;
...

Mark for Review

(1) Points
Position A
Position B (*)
Position C
Position D
Correct

12. Where would you place the BULK COLLECT statement in the following
example?
DECLARE
 TYPE DeptRecTab IS TABLE OF departments%ROWTYPE;
 dept_recs DeptRecTab;
CURSOR c1 IS
SELECT department_id, department_name, manager_id, location_id
  -- Position A
  FROM departments
  WHERE department_id > 70;
BEGIN
 OPEN c1
  -- Position B;
 FETCH c1
  -- Position C
 INTO dept_recs;
END;

Mark for Review

(1) Points
Position A
Position B
Position C (*)
Correct

13. FORALL can be used with any DML statement. True or False?


Mark for Review

(1) Points
True (*)
False
Correct

14. In the following example, where do you place the phrase


DETERMINISTIC?
CREATE OR REPLACE FUNCTION total_sal
  (p_dept_id IN -- Position A
employees.department_id%TYPE)
  RETURN NUMBER -- Position B
    IS v_total_sal NUMBER;
BEGIN
  SELECT SUM(salary) INTO v_total_sal
    FROM employees WHERE department_id = p_dept_in;
  RETURN v_total_sal -- Position C;
END total_sal;
Mark for Review

(1) Points
Position A
Position B (*)
Position C
Correct

15. What is wrong with this code example?


CREATE OR REPLACE PROCEDURE insert_emps IS
  TYPE t_emp IS TABLE OF employees%ROWTYPE INDEX BY
BINARY_INTEGER;
   v_emptab t_emp;
BEGIN
   FORALL i IN v_emptab.FIRST..v_emptab.LAST
     INSERT INTO employees VALUES v_emptab(i);
   END LOOP;
END insert_emps;

Mark for Review

(1) Points
FORALL does not require END LOOP. (*)
v_emptab is incorrectly typed.
The phrase should be FOR ALL.
Nothing is wrong; it will compile successfully.
Correct
Previous

You might also like