ORACLE ACDEMY SEMISTER2

 TOTAL 50 QUESTIONS

Test: PL/SQL Database Programming Semester 1 Final Exam

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 5

(Answer all questions in this section)
1. Examine the following code. To display the salary of an employee, what must be coded at Point A?

DECLARE
    CURSOR emp_curs IS SELECT * FROM employees;
BEGIN
    FOR emp_rec IN emp_curs LOOP
       DBMS_OUTPUT.PUT_LINE( -- what goes here ? );
    END LOOP;
END;


(1) Points

2. There are no employees in department_id 75.
Which of the following is NOT a valid cursor FOR loop with a subquery?

(1) Points

3. What is wrong with the following code?

DECLARE
    CURSOR dept_curs IS SELECT * FROM departments;
BEGIN
    FOR dept_rec IN dept_curs LOOP
       DBMS_OUTPUT.PUT_LINE(dept_curs%ROWCOUNT || dept_rec.department_name):
    END LOOP;
    DBMS_OUTPUT.PUT_LINE(dept_rec.department_id);
END;


(1) Points

4. Examine the following code:

DECLARE
  CURSOR c IS SELECT * FROM employees FOR UPDATE;
  c_rec c%ROWTYPE;
BEGIN
  OPEN c;
  FOR i IN 1..20 LOOP
    FETCH c INTO c_rec;
     IF i = 6 THEN
     UPDATE employees SET first_name = 'Joe'
     WHERE CURRENT OF c;
    END IF;
  END LOOP;
  CLOSE c;
END;

Which employee row or rows will be updated when this block is executed?


(1) Points

5. User MARY has locked a row of the EMPLOYEES table. Now, user SAEED tries to open the following cursor:

CURSOR c IS
  SELECT * FROM employees
  FOR UPDATE WAIT 5;

What will happen when SAEED's session tries to fetch the row that MARY has locked?


(1) Points

Test: PL/SQL Database Programming Semester 1 Final Exam

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 5

(Answer all questions in this section)
6. Using parameters with a cursor, you can open and close the cursor several times in a block, returning a different active set each time. True or False?

(1) Points

7. What is one of the advantages of using parameters with a cursor?

(1) Points

8. There are 8 countries in REGION_ID 13 (Central America). What will happen when the following code is executed?

DECLARE
  CURSOR country_curs IS SELECT country_name FROM wf_countries
   WHERE region_id = 13;
  v_country_name wf_countries.country_name%TYPE;
BEGIN
  OPEN country_curs;
  WHILE country_curs%FOUND
  LOOP
   FETCH country_curs INTO v_country_name;
   DBMS_OUTPUT.PUT_LINE(v_country_name);
  END LOOP;
  CLOSE country_curs;
END;


(1) Points

9. Which one of the following statements is NOT true?

(1) Points

10. You have declared a cursor EMP_CURSOR to select many rows from the EMPLOYEES table. The following five statements will be in the executable section:

A  FETCH emp_cursor INTO v_empno,v_last_name;
B  OPEN emp_cursor;
C  END LOOP;
D  CLOSE emp_cursor;
E  LOOP

In which order should you code these statements?


(1) Points
 Page 2 of 10  

Test: PL/SQL Database Programming Semester 1 Final Exam

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 5

(Answer all questions in this section)
11. Which of these statements about implicit cursors is NOT true?

(1) Points

12. You have declared the following cursor:

CURSOR country_curs IS
  SELECT * FROM wf_countries
  ORDER BY country_name;

There are over 200 rows in the WF_COUNTRIES table, but you want to fetch and display only the first 25 rows.

How would you exit from the FETCH loop?


(1) Points

13. Look at the following code:

DECLARE
  CURSOR emp_cursor IS
   SELECT employee_id, last_name, salary FROM employees;
  v_empcurs emp_cursor%ROWTYPE;

What is the data type of V_EMPCURS?


(1) Points

14. You can reference explicit cursor attributes directly in a SQL statement. True or False?

(1) Points

15. Which of the following is NOT allowed when using multiple cursors with parameters?

(1) Points
 Page 3 of 10  

Test: PL/SQL Database Programming Semester 1 Final Exam

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 5

(Answer all questions in this section)
16. Assume that table BIGDEPTS contains 100 rows, and table BIGEMPS contains 1000 rows, with 10 employees in each department. Consider the following code:

DECLARE
  CURSOR bigdept_cur IS
   SELECT * FROM bigdepts;
  CURSOR bigemp_cur IS
   SELECT * FROM bigemps;
BEGIN
  FOR dept_rec IN bigdept_cur LOOP
   DBMS_OUTPUT.PUT_LINE (dept_rec.department_name);
   FOR emp_rec IN bigemp_cur LOOP
    IF emp_rec.department_id=dept_rec.department_id
     THEN DBMS_OUTPUT.PUT_LINE (emp_rec.last_name);
    END IF;
   END LOOP;
  END LOOP;
END;

Why is this code inefficient?


(1) Points

Section 6

(Answer all questions in this section)
17. Which of these PL/SQL data structures can NOT store a collection?

(1) Points

18. The following code declares a PL/SQL record with the same structure as a row of the departments table. True or False?

DECLARE
    v_dept_rec departments%ROWTYPE;
...


(1) Points

Section 7

(Answer all questions in this section)
19. Using two nested blocks, a TOO_MANY_ROWS exception is raised within the inner block. Which of the following exception handlers will successfully handle the exception?

(1) Points

20. What will be displayed when the following code is executed?

<< outer>>
DECLARE
    v_myvar NUMBER;
BEGIN
    v_myvar := 25;
    DECLARE
       v_myvar NUMBER := 100;
    BEGIN
       outer.v_myvar := 30;
       v_myvar := v_myvar / 0;
       outer.v_myvar := 35;
    END;
    v_myvar := 40;
EXCEPTION
    WHEN ZERO_DIVIDE THEN
       DBMS_OUTPUT.PUT_LINE(v_myvar);
END;


(1) Points
 Page 4 of 10  

Test: PL/SQL Database Programming Semester 1 Final Exam

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 7

(Answer all questions in this section)
21. The following line of code is correct. True or False?
RAISE_APPLICATION_ERROR(-21001,'My error message');

(1) Points

22. The following three steps must be performed to use a user-defined exception: - Raise the exception - Handle the exception - Declare the exception In what sequence must these steps be performed?

(1) Points

23. User-defined exceptions must be declared explicitly by the programmer, but then are raised automatically by the Oracle Server. True or False?

(1) Points

24. Which of the following EXCEPTION sections is constructed correctly? (Choose three.)

(1) Points

25. Which of these exceptions can be handled by an EXCEPTION section in a PL/SQL block?

(1) Points
 Page 5 of 10  

Test: PL/SQL Database Programming Semester 1 Final Exam

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 7

(Answer all questions in this section)
26. Which of the following is NOT an advantage of including an exception handler in a PL/SQL block?

(1) Points

27. Which of the following is NOT a predefined Oracle Server error?

(1) Points

28. An ORA-1400 exception is raised if an attempt is made to insert a null value into a NOT NULL column. DEPARTMENT_ID is the primary key of the DEPARTMENTS table. What will happen when the following code is executed?

DECLARE
    e_not_null EXCEPTION;
BEGIN
    PRAGMA EXCEPTION_INIT(e_not_null, -1400);
    INSERT INTO departments (department_id, department_name)
       VALUES(null, 'Marketing');
EXCEPTION
    WHEN e_not_null THEN
       DBMS_OUTPUT.PUT_LINE('Cannot be null');
END;


(1) Points

29. What is the correct syntax to associate an exception named EXCEPNAME with the non-predefined Oracle Server error ORA-02292?

(1) Points

Section 8

(Answer all questions in this section)
30. Which one of the following statements about formal and actual parameters is true?

(1) Points
 Page 6 of 10  

Test: PL/SQL Database Programming Semester 1 Final Exam

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 8

(Answer all questions in this section)
31. What is the correct syntax to create procedure MYPROC that accepts two number parameters X and Y?

(1) Points

32. Which of the following keywords MUST be included in every PL/SQL procedure definition? (Choose three.)

(1) Points

33. A stored procedure add_dept may be invoked by the following command in Application Express. True or False?

BEGIN
  add_dept;
END;


(1) Points

34. A programmer wants to create a PL/SQL procedure named EMP_PROC. What will happen when the following code is executed?

CREATE OR REPLACE PROCEDURE emp_proc IS
    v_salary employees.salary%TYPE;
BEGIN
    SELECT salary INTO v_salary FROM employees
       WHERE employee_id = 999;
    DBMS_OUTPUT.PUT_LINE('The salary is: ' || v_salary);
END;


(1) Points

35. Which parameter mode is the default?

(1) Points
 Page 7 of 10  

Test: PL/SQL Database Programming Semester 1 Final Exam

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 8

(Answer all questions in this section)
36. Which kind of parameters cannot have a DEFAULT value?

(1) Points

Section 9

(Answer all questions in this section)
37. The function avg_ann_sal returns the average annual salary for a particular department. The example below is a valid use of this function. True or False?

SELECT first_name, last_name
FROM employees
WHERE avg_ann_sal(20) > 15000;


(1) Points

38. Which of the following is NOT a benefit of user-defined functions?

(1) Points

39. Which of the following is a benefit of user-defined functions? (Choose 3)

(1) Points

40. Which statement is true regarding the following subprogram?

PROCEDURE at_proc IS
 PRAGMA AUTONOMOUS_TRANSACTION;
 dept_id NUMBER := 90;
 BEGIN
   UPDATE ...
   INSERT ...
 END at_proc;


(1) Points
 Page 8 of 10  

Test: PL/SQL Database Programming Semester 1 Final Exam

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 9

(Answer all questions in this section)
41. User BOB creates procedure MYPROC using the default Definer's Rights. BOB then executes:
    GRANT EXECUTE ON bob.myproc TO ted;
When TED invokes BOB.MYPROC, whose privileges are checked?

(1) Points

42. 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?


(1) Points

43. USERB creates a function called SEL_PROC which includes the statement:

SELECT ... FROM usera.employees ...;

USERC needs to execute UserB's procedure. What privileges are needed for this to work correctly? (Choose two.)


(1) Points

44. 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?

(1) Points

45. What is one of the main purposes of the Data Dictionary?

(1) Points
 Page 9 of 10  

Test: PL/SQL Database Programming Semester 1 Final Exam

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 9

(Answer all questions in this section)
46. To create a function successfully,the first step is to test the code in an anonymous block.

(1) Points

47. To create a function successfully, the following steps should be performed.

A   Re-execute the code until it compiles correctly
B   Write the code containing the CREATE or REPLACE FUNCTION followed by the function code
C   Test the function from a SQL statement or an anonymous block
D   If the function fails to compile, correct the errors
E   Load the code into Application Express
F   Execute the code in Application Express

What is the correct order to perform these steps?


(1) Points

48. Function GET_JOB accepts an employee id as input and returns that employee's job id. Which of the following calls to the function will NOT work?

(1) Points

49. Which view would you query to see the detailed code of a procedure?

(1) Points

50. You want to remove the procedure NO_NEED from your schema. You execute:
DROP PROCEDURE no_need;

Which Data Dictionary views are updated automatically?


(1) Points
 Page 10 of 10 

Comments

Popular Posts