PLSQL Semester 2 Mid Term Exam
PLSQL Semester 2 Mid Term Exam
Section 10
1. Package MYPACK contains procedure MYPROC. You can see which parameters
MYPROC uses by executing: DESCRIBE mypack.myproc. True or False? (1) Points
True
False (*)
2. Which one of the following can NOT be part of a Package ? (1) Points
Procedures
Explicit cursors
Triggers (*)
Functions
Global variables
3. What is wrong with the following syntax for creating a package specification?
CREATE OR REPLACE PACKAGE mypack IS
g_constant1 NUMBER(6) := 100;
FUNCTION func1 (p_param1 IN VARCHAR2);
FUNCTION func2;
END mypack;
(1) Points
4. Which part of a package must be created first, the specification or the body? (1) Points
The body
The specification (*)
The specification and body must be created at the same time.
It does not matter which is created first.
The body can be created first, but only if the package has no specification.
The SELECT will fail because you cannot return SQL%ROWCOUNT from a packaged
function.
The SELECT will fail because you cannot call packaged functions from within a SQL
statement.
The SELECT will fail because you cannot execute a DML statement from within a query.
The SELECT will succeed because it is referencing a different table from the function. (*)
ol_pack.subprog('Jane',30);
ol_pack.subprog(param1=>'Jane',param2=>30); (*)
v_number := ol_pack.subprog(p1=>'Jane');
v_date := ol_pack.subprog('Jane',30); (*)
7. We never need to use a forward declaration when invoking a public subprogram. True or
False? (1) Points
True (*)
False
8. Which of the following are not allowed in a bodiless package? (Choose three) (1) Points
(Choose all correct answers)
Subprograms (*)
Global variables
Private variables (*)
User-defined exceptions
DML statements (*)
9. Which of the following statements about a package initialization block is true? (1) Points
Section 10
11. We want to remove the specification (but not the body) of package BIGPACK from the
database. Which of the following commands will do this? (1) Points
12. Your schema contains four packages, each having a specification and a body. You have
also been granted privileges to access three packages (and their bodies) in other users'
schemas. What will be displayed by the following query?
SELECT COUNT(*) FROM ALL_OBJECTS
WHERE object_type LIKE 'PACK%'
AND owner <> USER;
(1) Points
14
7
3
6 (*)
0
The packaage will not compile because you cannot declare a cursor in the specification. (*)
TAXPROC is a public procedure and TAXFUNC is a private function
14. We need to declare a package variable named MYVAR, which can be referenced by any
subprogram in the package but can NOT be referenced from outside the package. In the
following code, where should MYVAR be declared?
CREATE OR REPLACE PACKAGE varpack IS
-- Point A
...
END varpack;
CREATE OR REPLACE PACKAGE BODY varpack IS
-- Point B
PROCEDURE varproc IS
-- Point C
BEGIN
...
END varproc;
PROCEDURE ...
...
-- Point D
END varpack;
(1) Points
Point A
Point B (*)
Point C
Point D
Point B or Point C, they will both work
Section 11
15. A cursor is declared in a package specification. User SIOBHAN opens the cursor and
fetches the first three rows from the cursor's active set, but does not close the cursor.
User FRED now connects to the database. FRED can immediately fetch the next three rows
without opening the cursor. True or False? (1) Points
True
False (*)
User HAZEL now connects to the database. Both users immediately execute:
BEGIN
DBMS_OUTPUT.PUT_LINE(multipack.g_myvar);
END;
17. Why is it better to use DBMS_OUTPUT only in anonymous blocks, not inside stored
subprograms such as procedures? (1) Points
UTL_FILE.CREATE('FILESDIR','EMP_REPORT.TXT');
UTL_FILE.FOPEN('C:\NEWFILES\EMP_REPORT.TXT','w');
UTL_FILE.FOPEN('FILESDIR','EMP_REPORT.TXT','w'); (*)
UTL_FILE.OPEN('FILESDIR','EMP_REPORT.TXT','c');
True (*)
False
20. Which of the following best describes the purpose of the UTL_FILE package? (1) Points
It is used to load binary files such as employees' photos into the database.
It is used to read and write text files stored outside the database. (*)
It is used to find out how much free space is left on an operating system disk.
It is used to query CHAR and VARCHAR2 columns in tables.
Section 12
21. Which of the following SQL statements can be included in a PL/SQL block only by
using Dynamic SQL? (Choose two.) (1) Points (Choose all correct answers)
DELETE
SAVEPOINT
ALTER (*)
SELECT ..... FOR UPDATE NOWAIT
GRANT (*)
22. A SQL statement can pass through several stages. Which of the following is NOT one of
these stages? (1) Points
BIND
FETCH
PARSE
RETURN (*)
EXECUTE
23. Name two reasons for using Dynamic SQL. (1) Points (Choose all correct answers)
Provide the ability to execute SQL statements whose structure is unknown until execution
time. (*)
Provide the ability to handle mutating rows when executing a statement involving the same
table.
Allow fetch of data for DML statements.
Enables session-control statements to be written and executed from PL/SQL. (*)
24. MARY wants HENRY to be able to query her EMPLOYEES table. Mary executes the
following code:
DECLARE
v_grant_stmt VARCHAR2(50);
BEGIN
v_grant_stmt := 'GRANT SELECT ON employees TO henry';
DBMS_SQL.EXECUTE(v_grant_stmt);
END;
Mary has successfully granted the privilege to Henry. True or False?
(1) Points
True
False (*)
25. You want to take make a copy of all the cities in the world listed in the cities table, which
contains millions of rows. The following procedure accomplish this efficiently. True or False?
CREATE OR REPLACE PROCEDURE copy_cities IS
TYPE t_cities IS TABLE OF cities%ROWTYPE INDEX BY BINARY_INTEGER;
v_citiestab t_emp;
BEGIN
SELECT * BULK COLLECT INTO v_citiestab FROM cities;
FORALL i IN v_citiestab.FIRST..v_citiestab.LAST
INSERT INTO new_cities VALUES v_citiestab(i);
END copy_cities;
(1) Points
True (*)
False
26. All but which of the following are benefits of using the NOCOPY hint? (Choose two)
(1) Points
(Choose all correct answers)
28. To create a list of the top 20 movies from a catalog of millions of titles, the following
statement grabs those rows using a collection. True or False?
...
TYPE nametab IS TABLE OF movies.title%TYPE;
Title_tab nametab;
...
SELECT title BULK COLLECT INTO title_tab FROM movies
ORDER BY rental_count DESC;
...
(1) Points
True (*)
False
Section 13
29. What is the purpose of using the CALL statement in a trigger? (1) Points
It allows an INSTEAD OF trigger to be a statement trigger.
It allows the trigger body code to be placed in a separate procedure. (*)
It prevents cascading triggers.
It allows the trigger body code to be placed in a separate procedure or function.
It allows both DML events and DDL events to be handled using a single trigger.
30. A trigger automatically inserts a row into a logging table every time a user's session
receives this error message:
ORA-00942: table or view does not exist
What kind of trigger is this? (1) Points
A row trigger
A statement trigger
A database event trigger (*)
A DDL trigger
An AFTER trigger
True
False (*)
34. A trigger can be created in the database or within an application. True or False? (1)
Points
True (*)
False
35. You can use a trigger to prevent rows from being deleted from the EMPLOYEES table
on Mondays. True or False? (1) Points
True (*)
False
36. Which of the following are good guidelines to follow when creating a database trigger?
(Choose two.) (1) Points (Choose all correct answers)
37. A trigger can be a public subprogram within a PL/SQL package. True or False? (1)
Points
True
False (*)
38. A business rule states that an employee's salary cannot be greater than 99,999.99 or less
than 0. The best way to enforce this rule is by using: (1) Points
39. INSTEAD OF triggers are always row triggers, even if FOR EACH ROW is omitted.
True or False? (1) Points
True (*)
False
40. What is the event that will cause the trigger on the emp_details view below to fire?
CREATE OR REPLACE TRIGGER new_emp_dept
INSTEAD OF INSERT ON emp_details
BEGIN
INSERT INTO new_emps
VALUES (:NEW.employee_id, :NEW.last_name,
:NEW.salary, :NEW.department_id);
new_depts
SET dept_sal = dept_sal + :NEW.salary
WHERE department_id = :NEW.department_id;
END;
(1) Points
Section 13
41. Which of the following can NOT be coded in the body of a DML trigger? (Choose two.)
(1) Points
(Choose all correct answers)
IF DELETING THEN
IF SELECTING THEN (*)
IF INSERTING THEN
IF UPDATING ('JOB_ID') THEN
IF OTHERS THEN (*)
42. Examine the following trigger. It should raise an application error if a user tries to
update an employee's last name. It should allow updates to all other columns of the
EMPLOYEES table. What should be coded at line A?
CREATE TRIGGER stop_ln_trigg
BEFORE UPDATE ON employees
BEGIN
-- Line A
RAISE_APPLICATION_ERROR(-20201,'Updating last name not allowed');
END IF;
END;
(1) Points
44. There are five employees in department 50. The following trigger is created:
CREATE TRIGGER upd_emp
AFTER UPDATE ON employees
BEGIN
INSERT INTO audit_table VALUES (USER, SYSDATE);
END;
One (*)
Two
Five
Six
None of the above
46. You need to create a trigger that will fire whenever an employee's salary or job_id is
updated, but not when any other column of the EMPLOYEES table is updated. Which of the
following is the correct syntax to do this? (1) Points
48. Which dictionary view shows the detailed code of a trigger body? (1) Points
USER_SOURCE
USER_TRIGGERS (*)
USER_OBJECTS
USER_DML_TRIGGERS
USER_SUBPROGRAMS
49. MARY and JOE's schemas each contain an EMPLOYEES table. JOE creates the
following trigger:
CREATE TRIGGER upd_trigg
AFTER DELETE ON joe.employees
FOR EACH ROW
BEGIN
DELETE FROM mary.employees
WHERE employee_id = :OLD.employee_id;
END;
A third user TOM needs to delete rows from JOE's EMPLOYEES table. What object
privileges will TOM and JOE need?
(1) Points
TOM does not need any object privileges, but JOE needs DELETE on both
TOM.EMPLOYEES and MARY.EMPLOYEES
50. Which of the following will remove a trigger in your schema named EMP_TRIGG from
the database? (1) Points
Section 10
1. Your schema contains four packages, each having a specification and a body. You have
also been granted privileges to access three packages (and their bodies) in other users'
schemas. What will be displayed by the following query?
SELECT COUNT(*) FROM ALL_OBJECTS
WHERE object_type LIKE 'PACK%'
AND owner <> USER;
(1) Points
14
7
3
6 (*)
0
2. We want to remove the specification (but not the body) of package BIGPACK from the
database. Which of the following commands will do this? (1) Points
3. A package contains both public and private subprograms. Which one of the following
statements is true? (1) Points
4. Package OLDPACK is in your schema. What will happen when the following statement is
executed?
DROP PACKAGE oldpack; (1) Points
5. Which of the following will display the detailed code of the subprograms in package
DEPTPACK in your schema ? (1) Points
6. Package MYPACK contains procedure MYPROC. You can see which parameters
MYPROC uses by executing: DESCRIBE mypack.myproc. True or False? (1) Points
True
False (*)
7. Which of the following are good reasons for creating and using Packages?
Related procedures, functions and variables can be grouped together as a single unit
We can recompile the package body without having to recompile the specification
We can create packages without needing any system privileges
We can declare INDEX BY tables and use them as parameters
(1) Points
A and B
A, B and C
A and C
A, B and D (*)
A, B, C and D
8. Which part of a package must be created first, the specification or the body? (1) Points
The body
The specification (*)
The specification and body must be created at the same time.
It does not matter which is created first.
The body can be created first, but only if the package has no specification.
9. Which of the following statements about packages is NOT true ? (1) Points
10. Which two of these declarations cannot be in the same package specification?
1 and 2
1 and 3 (*)
2 and 3
3 and 4
1 and 4
ol_pack.subprog('Jane',30);
ol_pack.subprog(param1=>'Jane',param2=>30); (*)
v_number := ol_pack.subprog(p1=>'Jane');
v_date := ol_pack.subprog('Jane',30); (*)
12. The following example shows a valid record data type and variaable. True or False?
TYPE DeptRecTyp
IS RECORD (deptid NUMBER(4) NOT NULL := 99,
dname departments.department_name%TYPE,
loc departments.location_id%TYPE,
region regions%ROWTYPE );
dept_rec DeptRecTyp;
(1) Points
True (*)
False
FUNCTION sal_ok;
FUNCTION sal_ok(pf_salary NUMBER);
FUNCTION sal_ok(pf_salary NUMBER) RETURN BOOLEAN; (*)
PROCEDURE upd_emp (p_empno IN NUMBER, p_salary IN NUMBER);
Nothing is needed at Line A
14. Which of the following are not allowed in a bodiless package? (Choose three) (1) Points
(Choose all correct answers)
Subprograms (*)
Global variables
Private variables (*)
User-defined exceptions
DML statements (*)
Section 11
15. Why is it better to use DBMS_OUTPUT only in anonymous blocks, not inside stored
subprograms such as procedures? (1) Points
16. Which of the following exceptions can be raised ONLY when using the UTL_FILE
package? (Choose two). (1) Points (Choose all correct answers)
INVALID_PATH (*)
NO_DATA_FOUND
VALUE_ERROR
READ_ERROR (*)
E_MYEXCEP
17. The UTL_FILE package can be used to create binary files such as JPEGs as well as text
files. True or False? (1) Points
True
False (*)
18. The DBMS_OUTPUT.PUT procedure places text in a buffer but does not display the
contents of the buffer. True or False? (1) Points
True (*)
False
19. Package CURSPACK declares a global cursor in the package specification. The package
contains three public procedures: OPENPROC opens the cursor; FETCHPROC fetches 5
rows from the cursor's active set; CLOSEPROC closes the cursor.
What will happen when a user session executes the following commands in the order shown?
curspack.openproc; -- line 1
curspack.fetchproc; -- line 2
curspack.fetchproc; -- line 3
curspack.openproc; -- line 4
curspack.fetchproc; -- line 5
curspack.closeproc; -- line 6
(1) Points
20. A cursor is declared in a package specification. User SIOBHAN opens the cursor and
fetches the first three rows from the cursor's active set, but does not close the cursor.
User FRED now connects to the database. FRED can immediately fetch the next three rows
without opening the cursor. True or False? (1) Points
True
False (*)
21. A SQL statement can pass through several stages. Which of the following is NOT one of
these stages? (1) Points
BIND
FETCH
PARSE
RETURN (*)
EXECUTE
22. You want to create a function which drops a table. You write the following code:
CREATE OR REPLACE FUNCTION droptab
(p_tab_name IN VARCHAR2)
RETURN BOOLEAN IS
BEGIN
DROP TABLE p_tab_name;
RETURN TRUE;
EXCEPTION
WHEN OTHERS THEN RETURN FALSE;
END;
Why will this procedure not compile successfully?
(1) Points
23. Which of the following SQL statements can be included in a PL/SQL block only by
using Dynamic SQL? (Choose two.) (1) Points (Choose all correct answers)
DELETE
SAVEPOINT
ALTER (*)
SELECT ..... FOR UPDATE NOWAIT
GRANT (*)
24. Name two reasons for using Dynamic SQL. (1) Points (Choose all correct answers)
Provide the ability to execute SQL statements whose structure is unknown until execution
time. (*)
Provide the ability to handle mutating rows when executing a statement involving the same
table.
Allow fetch of data for DML statements.
Enables session-control statements to be written and executed from PL/SQL. (*)
25. What is the correct syntax to use the RETURNING phrase at Position A?
DECLARE
TYPE EmpRec IS RECORD (last_name employees.last_name%TYPE, salary
employees.salary%TYPE);
emp_info EmpRec;
emp_id NUMBER := 100;
BEGIN
UPDATE employees SET salary = salary * 1.1 WHERE employee_id = emp_id -- Position
A
dbms_output.put_line('Just gave a raise to ' || emp_info.last_name || ', who now makes ' ||
emp_info.salary);
END;
(1) Points
26. 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;
(1) Points
Position A
Position B
Position C (*)
28. FORALL can be used with any DML statement. True or False? (1) Points
True (*)
False
Section 13
29. Which kinds of trigger can cause a mutating table problem? (Choose two.) (1) Points
(Choose all correct answers)
31. You want to prevent any objects in your schema from being altered or dropped. You
decide to create the following trigger:
CREATE TRIGGER stop_ad_trigg
-- Line A
BEGIN
RAISE_APPLICATION_ERROR(-20203,'Invalid Operation');
END;
What should you code at Line A ?
(1) Points
33. You can use a trigger to prevent rows from being deleted from the EMPLOYEES table
on Mondays. True or False? (1) Points
True (*)
False
34. Which of the following are NOT stored inside the database? (Choose two.) (1) Points
(Choose all correct answers)
35. A trigger can be created in the database or within an application. True or False? (1)
Points
True (*)
False
36. Which of the following are good guidelines to follow when creating a database trigger?
(Choose two.) (1) Points (Choose all correct answers)
pack1.packproc(25); (*)
SELECT func1(100) FROM dual;
trigg1;
IF pack1.packfunc(40) THEN ...
IF func1(75) THEN ... (*)
38. A business rule states that an employee's salary cannot be greater than 99,999.99 or less
than 0. The best way to enforce this rule is by using: (1) Points
39. With which kind of trigger can the :OLD and :NEW qualifiers be used? (1) Points
DDL triggers
Database Event triggers
Statement triggers
Row triggers (*)
AFTER triggers
41. Which of the following can NOT be coded in the body of a DML trigger? (Choose two.)
(1) Points
(Choose all correct answers)
IF DELETING THEN
IF SELECTING THEN (*)
IF INSERTING THEN
IF UPDATING ('JOB_ID') THEN
IF OTHERS THEN (*)
True
False (*)
43. What is wrong with the following code example for a compound trigger?
CREATE OR REPLACE TRIGGER log_emps
FOR UPDATE OF salary ON employees
COMPOUND TRIGGER
TYPE t_log_emp IS TABLE OF log_table%ROWTYPE
INDEX BY BINARY_INTEGER;
log_emp_tab t_log_emp;
AFTER STATEMENT IS
BEGIN
-- some action
END AFTER STATEMENT;
END log_emps;
(1) Points
44. Which dictionary view shows the detailed code of a trigger body? (1) Points
USER_SOURCE
USER_TRIGGERS (*)
USER_OBJECTS
USER_DML_TRIGGERS
USER_SUBPROGRAMS
45. After the following SQL statement is executed, all the triggers on the DEPARTMENTS
table will no longer fire, but will remain in the database. True or False?
ALTER TABLE departments DISABLE ALL TRIGGERS;
(1) Points
True (*)
False
46. Which of the following will remove a trigger in your schema named EMP_TRIGG from
the database? (1) Points
48. There are five employees in department 50. The following trigger is created:
CREATE TRIGGER upd_emp
AFTER UPDATE ON employees
BEGIN
INSERT INTO audit_table VALUES (USER, SYSDATE);
END;
One (*)
Two
Five
Six
None of the above
49. The following code will successfully create emp_trigg: True or False?
CREATE OR REPLACE TRIGGER emp_trigg
BEFORE DELETE OF salary ON employees
BEGIN
RAISE_APPLICATION_ERROR(-20202,'Deleting salary is not allowed');
END;
(1) Points
True
False (*)
50. A DML statement trigger fires only once for each triggering DML statement, while a row
trigger fires once for each row processed by the triggering statement. True or False? (1)
Points
True (*)
False
Section 10
1. Your schema contains four packages, each having a specification and a body. You have
also been granted privileges to access three packages (and their bodies) in other users'
schemas. What will be displayed by the following query?
SELECT COUNT(*) FROM ALL_OBJECTS
WHERE object_type LIKE 'PACK%'
AND owner <> USER;
(1) Points
14
7
3
6 (*)
0
2. We want to remove the specification (but not the body) of package BIGPACK from the
database. Which of the following commands will do this? (1) Points
DROP PACKAGE bigpack;
DROP PACKAGE SPECIFICATION bigpack;
DROP PACKAGE bigpack SPECIFICATION;
DROP PACKAGE HEADER bigpack;
None of the above (*)
3. A package contains both public and private subprograms. Which one of the following
statements is true? (1) Points
4. Package OLDPACK is in your schema. What will happen when the following statement is
executed?
DROP PACKAGE oldpack; (1) Points
5. Which of the following will display the detailed code of the subprograms in package
DEPTPACK in your schema ? (1) Points
True
False (*)
7. Which of the following are good reasons for creating and using Packages?
Related procedures, functions and variables can be grouped together as a single unit
We can recompile the package body without having to recompile the specification
We can create packages without needing any system privileges
We can declare INDEX BY tables and use them as parameters
(1) Points
A and B
A, B and C
A and C
A, B and D (*)
A, B, C and D
8. Which part of a package must be created first, the specification or the body? (1) Points
The body
The specification (*)
The specification and body must be created at the same time.
It does not matter which is created first.
The body can be created first, but only if the package has no specification.
9. Which of the following statements about packages is NOT true ? (1) Points
10. Which two of these declarations cannot be in the same package specification?
1 and 2
1 and 3 (*)
2 and 3
3 and 4
1 and 4
11. Examine the following package code:
CREATE OR REPLACE PACKAGE ol_pack IS
PROCEDURE subprog (p1 IN VARCHAR2, p2 IN NUMBER);
PROCEDURE subprog (param1 IN CHAR, param2 IN NUMBER);
FUNCTION subprog (param1 IN VARCHAR2, param2 IN NUMBER) RETURN DATE;
END ol_pack;
Which of the following calls will be successful? (Choose two.)
(1) Points (Choose all correct answers)
ol_pack.subprog('Jane',30);
ol_pack.subprog(param1=>'Jane',param2=>30); (*)
v_number := ol_pack.subprog(p1=>'Jane');
v_date := ol_pack.subprog('Jane',30); (*)
12. The following example shows a valid record data type and variaable. True or False?
TYPE DeptRecTyp
IS RECORD (deptid NUMBER(4) NOT NULL := 99,
dname departments.department_name%TYPE,
loc departments.location_id%TYPE,
region regions%ROWTYPE );
dept_rec DeptRecTyp;
(1) Points
True (*)
False
FUNCTION sal_ok;
FUNCTION sal_ok(pf_salary NUMBER);
FUNCTION sal_ok(pf_salary NUMBER) RETURN BOOLEAN; (*)
PROCEDURE upd_emp (p_empno IN NUMBER, p_salary IN NUMBER);
Nothing is needed at Line A
14. Which of the following are not allowed in a bodiless package? (Choose three) (1) Points
(Choose all correct answers)
Subprograms (*)
Global variables
Private variables (*)
User-defined exceptions
DML statements (*)
Section 11
15. Why is it better to use DBMS_OUTPUT only in anonymous blocks, not inside stored
subprograms such as procedures? (1) Points
16. Which of the following exceptions can be raised ONLY when using the UTL_FILE
package? (Choose two). (1) Points (Choose all correct answers)
INVALID_PATH (*)
NO_DATA_FOUND
VALUE_ERROR
READ_ERROR (*)
E_MYEXCEP
17. The UTL_FILE package can be used to create binary files such as JPEGs as well as text
files. True or False? (1) Points
True
False (*)
18. The DBMS_OUTPUT.PUT procedure places text in a buffer but does not display the
contents of the buffer. True or False? (1) Points
True (*)
False
19. Package CURSPACK declares a global cursor in the package specification. The package
contains three public procedures: OPENPROC opens the cursor; FETCHPROC fetches 5
rows from the cursor's active set; CLOSEPROC closes the cursor.
What will happen when a user session executes the following commands in the order shown?
curspack.openproc; -- line 1
curspack.fetchproc; -- line 2
curspack.fetchproc; -- line 3
curspack.openproc; -- line 4
curspack.fetchproc; -- line 5
curspack.closeproc; -- line 6
(1) Points
20. A cursor is declared in a package specification. User SIOBHAN opens the cursor and
fetches the first three rows from the cursor's active set, but does not close the cursor.
User FRED now connects to the database. FRED can immediately fetch the next three rows
without opening the cursor. True or False? (1) Points
True
False (*)
21. A SQL statement can pass through several stages. Which of the following is NOT one of
these stages? (1) Points
BIND
FETCH
PARSE
RETURN (*)
EXECUTE
22. You want to create a function which drops a table. You write the following code:
CREATE OR REPLACE FUNCTION droptab
(p_tab_name IN VARCHAR2)
RETURN BOOLEAN IS
BEGIN
DROP TABLE p_tab_name;
RETURN TRUE;
EXCEPTION
WHEN OTHERS THEN RETURN FALSE;
END;
Why will this procedure not compile successfully?
(1) Points
DELETE
SAVEPOINT
ALTER (*)
SELECT ..... FOR UPDATE NOWAIT
GRANT (*)
24. Name two reasons for using Dynamic SQL. (1) Points (Choose all correct answers)
Provide the ability to execute SQL statements whose structure is unknown until execution
time. (*)
Provide the ability to handle mutating rows when executing a statement involving the same
table.
Allow fetch of data for DML statements.
Enables session-control statements to be written and executed from PL/SQL. (*)
25. What is the correct syntax to use the RETURNING phrase at Position A?
DECLARE
TYPE EmpRec IS RECORD (last_name employees.last_name%TYPE, salary
employees.salary%TYPE);
emp_info EmpRec;
emp_id NUMBER := 100;
BEGIN
UPDATE employees SET salary = salary * 1.1 WHERE employee_id = emp_id -- Position
A
dbms_output.put_line('Just gave a raise to ' || emp_info.last_name || ', who now makes ' ||
emp_info.salary);
END;
(1) Points
26. 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;
(1) Points
Position A
Position B
Position C (*)
28. FORALL can be used with any DML statement. True or False? (1) Points
True (*)
False
Section 13
29. Which kinds of trigger can cause a mutating table problem? (Choose two.) (1) Points
(Choose all correct answers)
31. You want to prevent any objects in your schema from being altered or dropped. You
decide to create the following trigger:
CREATE TRIGGER stop_ad_trigg
-- Line A
BEGIN
RAISE_APPLICATION_ERROR(-20203,'Invalid Operation');
END;
What should you code at Line A ?
(1) Points
33. You can use a trigger to prevent rows from being deleted from the EMPLOYEES table
on Mondays. True or False? (1) Points
True (*)
False
34. Which of the following are NOT stored inside the database? (Choose two.) (1) Points
(Choose all correct answers)
True (*)
False
36. Which of the following are good guidelines to follow when creating a database trigger?
(Choose two.) (1) Points (Choose all correct answers)
pack1.packproc(25); (*)
SELECT func1(100) FROM dual;
trigg1;
IF pack1.packfunc(40) THEN ...
IF func1(75) THEN ... (*)
38. A business rule states that an employee's salary cannot be greater than 99,999.99 or less
than 0. The best way to enforce this rule is by using: (1) Points
39. With which kind of trigger can the :OLD and :NEW qualifiers be used? (1) Points
DDL triggers
Database Event triggers
Statement triggers
Row triggers (*)
AFTER triggers
41. Which of the following can NOT be coded in the body of a DML trigger? (Choose two.)
(1) Points
(Choose all correct answers)
IF DELETING THEN
IF SELECTING THEN (*)
IF INSERTING THEN
IF UPDATING ('JOB_ID') THEN
IF OTHERS THEN (*)
True
False (*)
43. What is wrong with the following code example for a compound trigger?
CREATE OR REPLACE TRIGGER log_emps
FOR UPDATE OF salary ON employees
COMPOUND TRIGGER
TYPE t_log_emp IS TABLE OF log_table%ROWTYPE
INDEX BY BINARY_INTEGER;
log_emp_tab t_log_emp;
AFTER STATEMENT IS
BEGIN
-- some action
END AFTER STATEMENT;
END log_emps;
(1) Points
44. Which dictionary view shows the detailed code of a trigger body? (1) Points
USER_SOURCE
USER_TRIGGERS (*)
USER_OBJECTS
USER_DML_TRIGGERS
USER_SUBPROGRAMS
45. After the following SQL statement is executed, all the triggers on the DEPARTMENTS
table will no longer fire, but will remain in the database. True or False?
ALTER TABLE departments DISABLE ALL TRIGGERS;
(1) Points
True (*)
False
46. Which of the following will remove a trigger in your schema named EMP_TRIGG from
the database? (1) Points
48. There are five employees in department 50. The following trigger is created:
CREATE TRIGGER upd_emp
AFTER UPDATE ON employees
BEGIN
INSERT INTO audit_table VALUES (USER, SYSDATE);
END;
One (*)
Two
Five
Six
None of the above
49. The following code will successfully create emp_trigg: True or False?
CREATE OR REPLACE TRIGGER emp_trigg
BEFORE DELETE OF salary ON employees
BEGIN
RAISE_APPLICATION_ERROR(-20202,'Deleting salary is not allowed');
END;
(1) Points
True
False (*)
50. A DML statement trigger fires only once for each triggering DML statement, while a row
trigger fires once for each row processed by the triggering statement. True or False? (1)
Points
True (*)
False
3. The database administrator wants to write a log recordevery time an Oracle Server error
occurs in any user's session. The DBAcreates the following trigger:
4. You want to prevent any objects in your schema frombeing altered or dropped. You decide
to create the following trigger:
CREATE TRIGGER stop_ad_trigg--Line A
BEGIN
RAISE_APPLICATION_ERROR(-20203,'Invalid Operation');
END;
What should you code at Line A ?
8. You need to disable all triggers that are associatedwith DML statements on the
DEPARTMENTS table. Which of the following commands should you use?
9. After the following SQL statement is executed, all thetriggers on the DEPARTMENTS
table will no longer fire, but will remain inthe database. True or False?
ALTER TABLE departments DISABLE ALL TRIGGERS;
True (*)
False
An error message is displayed because youcannot drop a table that is associated with a
trigger.
The table is dropped and the trigger isdisabled.
The trigger is dropped but the table is notdropped.
Both the table and the trigger are dropped.(*)
None of the above.
11. A SQL statement canpass through several stages. Which of the following is NOT one of
thesestages?
BIND
FETCH
PARSE
RETURN (*)
EXECUTE
13. Which of the following SQL statements can be included ina PL/SQL block only by using
Dynamic SQL? (Choose two.) (Choose all correct answers)
DELETE
SAVEPOINT
ALTER (*)
SELECT ..... FOR UPDATE NOWAIT
GRANT (*)
SAVEPOINT
ALTER (*)
SELECT ..... FOR UPDATE NOWAIT
GRANT (*)
14. MARY wants HENRY to be able to query her EMPLOYEEStable. Mary executes the
following code:
DECLARE v_grant_stmt VARCHAR2(50);
BEGIN
v_grant_stmt := 'GRANT SELECT ON employees TO henry';
DBMS_SQL.EXECUTE(v_grant_stmt);
END;
Mary has successfully granted the privilege to Henry. True or False?
True
False (*)
Dick: 0, Hazel: 0
Both queries will fail because the syntax ofDBMS_OUTPUT.PUT_LINE is incorrect
18. A public function in a package is invoked from within aSQL statement. The function's
code can include a COMMIT statement. True or False?
True
False (*)
Declare the global variable as: g_taxrate NUMBER(2,2) := SELECT tax_rate FROM taxtab;
Create a database trigger that includes thefollowing code: SELECT tax_rate INTO
taxpack.g_taxrate FROM taxtab;
Add a private function to the package body ofTAXPACK, and invoke the function from the
user session.
Add a package initialization block to thepackage body of TAXPACK.(*)
20. Which two of these declarations cannot be in the same package specification?
PROCEDURE myproc (p1 NUMBER, p2 VARCHAR2);
PROCEDURE myproc (p1 VARCHAR2, p2 NUMBER);
PROCEDURE myproc (p1 NUMBER, p2 CHAR);
PROCEDURE myproc (p1 NUMBER);
1 and 2
1 and 3 (*)
2 and 3
3 and 4
1 and 4
21. Which of the followingare NOT stored inside the database? (Choose two.) (Choose all
correct answers)
A PL/SQL package specification
A database trigger
An anonymous block (*)
An application trigger (*)
A sequence
22. You can use a trigger to prevent rows from being deletedfrom the EMPLOYEES table on
Mondays. True or False?
True (*)
False
23. What type of database object would you create to writean auditing record automatically
every time a user connects to the database?
A procedure
A complex view
A trigger (*)
A function
A package
24. A business rule states that an employee's salary cannotbe greater than 99,999.99 or less
than 0. The best way to enforce thisrule is by using:
A datatype of NUMBER(7,2) for the SALARYcolumn
A database trigger
A check constraint (*)
An application trigger
A view
pack1.packproc(25); (*)
SELECT func1(100) FROM dual;
trigg1;
IF pack1.packfunc(40) THEN ...
IF func1(75) THEN ... (*)
26. You can code COMMIT and ROLLBACK statements in a trigger body. True or False?
True
False (*)
27. A trigger can be created in the database or within anapplication. True or False?
True (*)
False
29. Why is it better to use DBMS_OUTPUT only in anonymousblocks, not inside stored
subprograms such as procedures?
Because DBMS_OUTPUT cannot be used inside procedures
Because anonymous blocks display messageswhile the block is executing, while procedures
do not display anythinguntil their execution has finished
Because DBMS_OUTPUT should be used only fortesting and debugging PL/SQL code (*)
Because DBMS_OUTPUT can raise a NO_DATA_FOUND exception if used inside a
packaged procedure
30. Which of the following best describes the purpose of theUTL_FILE package?
It is used to load binary files such asemployees' photos into the database. employees' photos
into the database.
It is used to read and write text files stored outside the database. (*)
It is used to find out how much free space isleft on an operating system disk.
It is used to query CHAR and VARCHAR2 columnsin tables.
32. Every subprogram which has been declared in a package specification must also be
included in the package body. Triue or False?
True (*)
False
35. What is wrong with the following syntax for creating apackage specification?
END loc_trigg;
a trigger.
BEFORE DELETE OF locations (*)
and execute successfully.
The last line should be: You cannot use RAISE_APPLICATION_ERROR inside
The second line should be: You cannot use ROLLBACK inside a trigger.
Nothing is wrong, this trigger will compile
38. A DML statement trigger fires only once for eachtriggering DML statement, while a row
trigger fires once for each rowprocessed by the triggering statement. True or False?
True (*)
False
39. The following code will successfully create emp_trigg: True or False?
CREATE OR REPLACE TRIGGER emp_triggBEFORE DELETE OF salary ON
employeesBEGIN
RAISE_APPLICATION_ERROR(-20202,'Deleting salary is not allowed');
END;
True
False (*)
40. In a package, public components are declared in thespecification but private components
are not. True or False?
True (*)
False
42. Which of the following will display the detailed code of the subprograms in package
DEPTPACK in your schema ?
43. Package OLDPACK is in your schema. What will happen whenthe following statement is
executed?
DROP PACKAGE oldpack;
The body will be dropped but thespecification will be retained.
The specification will be dropped but thebody will be retained.
Both the specification and the body will bedropped. (*)
The statement will fail because you must dropthe body before you can drop the specification.
44. When a change is made to the detailed code of a publicprocedure in a package (but not to
the procedure's name or parameters),
both the specification and the body must be recompiled. True or False?
True
False (*)
45. Your schema contains four packages, each having aspecification and a body. You have
also been granted privileges to accessthree packages (and their bodies) in other users'
schemas. What will bedisplayed by the following query?
SELECT COUNT(*) FROM ALL_OBJECTSWHERE object_type LIKE 'PACK%'
AND owner <> USER;
14
7
3
6 (*)
0
46. We want to remove the specification (but not the body) of package BIGPACK from the
database.
Which of the following commands will do this?
48. With which kind of trigger can the :OLD and :NEWqualifiers be used?
DDL triggers
Database Event triggers
Statement triggers
Row triggers (*)
AFTER triggers
True
False (*)
50. Examine the following trigger. It should raise anapplication error if a user tries to update
an employee's last name. It should allow updates to all other columns of the EMPLOYEES
table. Whats hould be coded at line A?
CREATE TRIGGER stop_ln_triggBEFORE UPDATE ON employeesBEGIN
--Line A
RAISE_APPLICATION_ERROR(-20201,'Updating last name not allowed');
END IF;
END;
FUNCTION sal_ok;
FUNCTION sal_ok(pf_salary NUMBER);
FUNCTION sal_ok(pf_salary NUMBER) RETURN BOOLEAN; (*)
PROCEDURE upd_emp (p_empno IN NUMBER, p_salary IN NUMBER);
Nothing is needed at Line A
2. A public function in a package is invoked from within a SQL statement. The functions
code can include a COMMIT statement. True or False?
True
False (*)
3. Examine the following package code:
CREATE OR REPLACE PACKAGE ol_pack IS
PROCEDURE subprog (p1 IN VARCHAR2, p2 IN NUMBER);
PROCEDURE subprog (param1 IN CHAR, param2 IN NUMBER);
FUNCTION subprog (param1 IN VARCHAR2, param2 IN NUMBER) RETURN DATE;
END ol_pack;
ol_pack.subprog(Jane,30);
ol_pack.subprog(param1=>Jane,param2=>30); (*)
v_number := ol_pack.subprog(p1=>Jane);
v_date := ol_pack.subprog(Jane,30); (*)
4. Which of the following are not allowed in a bodiless package? (Choose three)
Subprograms (*)
Global variables
Private variables (*)
User-defined exceptions
DML statements (*)
6. When a change is made to the detailed code of a public procedure in a package (but not to
the procedures name or parameters), both the specification and the body must be recompiled.
True or False?
True
False (*)
The package body of TAXPACK also includes a function called TAXFUNC. Which one of
the following statements is NOT true?
The packaage will not compile because you cannot declare a cursor in the specification.
(*)
8. Your schema contains four packages, each having a specification and a body. You have
also been granted privileges to access three packages (and their bodies) in other users
schemas. What will be displayed by the following query?
SELECT COUNT(*) FROM ALL_OBJECTS
WHERE object_type LIKE PACK%
AND owner <> USER;
14
7
3
6 (*)
0
9. Package NEWPACK contains several procedures and functions, including private function
PRIVFUNC. From where can PRIVFUNC be invoked? (Choose two.)
10. Package OLDPACK is in your schema. What will happen when the following statement
is executed?
DROP PACKAGE oldpack;
Which of the following will correctly invoke the package subprograms? (Choose two.)
mypack.myfunc(22-JAN-07);
mypack.myproc(35);
(*)
myproc(40);
v_num := mypack.myproc(22);
13. What is wrong with the following syntax for creating a package specification?
CREATE OR REPLACE PACKAGE mypack IS
g_constant1 NUMBER(6) := 100;
FUNCTION func1 (p_param1 IN VARCHAR2);
FUNCTION func2;
END mypack;
14. Which of the following are good reasons for creating and using Packages?
Related procedures, functions and variables can be grouped together as a single unit
We can recompile the package body without having to recompile the specification
We can create packages without needing any system privileges
We can declare INDEX BY tables and use them as parameters
A and B
A, B and C
A and C
A, B and D (*)
A, B, C and D
15. Package CURSPACK declares a global cursor in the package specification. The package
contains three public procedures: OPENPROC opens the cursor; FETCHPROC fetches 5
rows from the cursors active set; CLOSEPROC closes the cursor.
What will happen when a user session executes the following commands in the order shown?
curspack.openproc; line 1
curspack.fetchproc; line 2
curspack.fetchproc; line 3
curspack.openproc; line 4
curspack.fetchproc; line 5
curspack.closeproc; line 6
16. A cursor is declared in a package specification. User SIOBHAN opens the cursor and
fetches the first three rows from the cursors active set, but does not close the cursor.
User FRED now connects to the database. FRED can immediately fetch the next three rows
without opening the cursor. True or False?
True
False (*)
17. Which of the following exceptions can be raised ONLY when using the UTL_FILE
package? (Choose two).
INVALID_PATH (*)
NO_DATA_FOUND
VALUE_ERROR
READ_ERROR (*)
E_MYEXCEP
18. The UTL_FILE package can be used to create binary files such as JPEGs as well as text
files. True or False?
True
False (*)
19. The DBMS_OUTPUT.PUT procedure places text in a buffer but does not display the
contents of the buffer. True or False?
True (*)
False
UTL_FILE.CREATE(FILESDIR,EMP_REPORT.TXT);
UTL_FILE.FOPEN(C:\NEWFILES\EMP_REPORT.TXT,w);
UTL_FILE.FOPEN(FILESDIR,EMP_REPORT.TXT,w); (*)
UTL_FILE.OPEN(FILESDIR,EMP_REPORT.TXT,c);
Provide the ability to execute SQL statements whose structure is unknown until
execution time. (*)
Provide the ability to handle mutating rows when executing a statement involving the same
table.
Allow fetch of data for DML statements.
Enables session-control statements to be written and executed from PL/SQL. (*)
22. You want to create a function which drops a table. You write the following code:
23. The following procedure adds a column of datatype DATE to the EMPLOYEES table.
The name of the new column is passed to the procedure as a parameter.
CREATE OR REPLACE PROCEDURE addcol
(p_col_name IN VARCHAR2) IS
v_first_string VARCHAR2(100) := ALTER TABLE EMPLOYEES ADD (;
v_second_string VARCHAR2(6) := DATE);
BEGIN
Line A
END;
Which of the following will work correctly when coded at line A? (Choose two.)
24. Which of the following SQL statements can be included in a PL/SQL block only by
using Dynamic SQL? (Choose two.)
DELETE
SAVEPOINT
ALTER (*)
SELECT .. FOR UPDATE NOWAIT
GRANT (*)
25. What is the correct syntax to use the RETURNING phrase at Position A?
DECLARE
TYPE EmpRec IS RECORD (last_name employees.last_name%TYPE, salary
employees.salary%TYPE);
emp_info EmpRec;
emp_id NUMBER := 100;
BEGIN
UPDATE employees SET salary = salary * 1.1 WHERE employee_id = emp_id Position
A
dbms_output.put_line(Just gave a raise to || emp_info.last_name || , who now makes ||
emp_info.salary);
END;
26. The following example code will compile successfully. True or False?
CREATE OR REPLACE PROCEDURE dept_proc IS
TYPE t_dept IS TABLE OF departments%ROWTYPE
INDEX BY BINARY_INTEGER;
BEGIN
(p_small_arg IN NUMBER, p_big_arg OUT NOCOPY t_dept);
remaining code
END dept_proc;
True
False (*)
27. You want to take make a copy of all the cities in the world listed in the cities table, which
contains millions of rows. The following procedure accomplish this efficiently. True or False?
CREATE OR REPLACE PROCEDURE copy_cities IS
TYPE t_cities IS TABLE OF cities%ROWTYPE INDEX BY BINARY_INTEGER;
v_citiestab t_emp;
BEGIN
SELECT * BULK COLLECT INTO v_citiestab FROM cities;
FORALL i IN v_citiestab.FIRST..v_citiestab.LAST
INSERT INTO new_cities VALUES v_citiestab(i);
END copy_cities;
True (*)
False
28. All but which of the following are benefits of using the NOCOPY hint? (Choose two)
Safer because it uses passing by value. (*)
Efficient since it uses less memory.
Uses a larger block of server memory for faster access. (*)
Faster because a single copy of the data is used.
Eliminates extra processing.
29. What is wrong with the following code?
30. A DML statement trigger fires only once for each triggering DML statement, while a row
trigger fires once for each row processed by the triggering statement. True or False?
True (*)
False
31. The following code will successfully create emp_trigg: True or False?
True
False (*)
32. There are five employees in department 50. The following trigger is created:
CREATE TRIGGER upd_emp
AFTER UPDATE ON employees
BEGIN
INSERT INTO audit_table VALUES (USER, SYSDATE);
END;
One (*)
Two
Five
Six
None of the above
33. You can code COMMIT and ROLLBACK statements in a trigger body. True or False?
True
False (*)
34. A trigger can be created in the database or within an application. True or False?
True (*)
False
35. What type of database object would you create to write an auditing record automatically
every time a user connects to the database?
A procedure
A complex view
A trigger (*)
A function
A package
36. A trigger can be a public subprogram within a PL/SQL package. True or False?
True
False (*)
37. Which of the following are good guidelines to follow when creating a database trigger?
(Choose two.)
True (*)
False
39. A trigger automatically inserts a row into a logging table every time a users session
receives this error message:
ORA-00942: table or view does not exist
What kind of trigger is this?
A row trigger
A statement trigger
A database event trigger (*)
A DDL trigger
An AFTER trigger
41. You want to prevent any objects in your schema from being altered or dropped. You
decide to create the following trigger:
CREATE TRIGGER stop_ad_trigg
Line A
BEGIN
RAISE_APPLICATION_ERROR(-20203,Invalid Operation);
END;
What should you code at Line A ?
42. Which of the following statements could cause a DDL trigger to fire?
43. You need to disable all triggers that are associated with DML statements on the
DEPARTMENTS table. Which of the following commands should you use?
44. Which dictionary view shows the detailed code of a trigger body?
USER_SOURCE
USER_TRIGGERS (*)
USER_OBJECTS
USER_DML_TRIGGERS
USER_SUBPROGRAMS
45. MARY and JOEs schemas each contain an EMPLOYEES table. JOE creates the
following trigger:
TOM does not need any object privileges, but JOE needs DELETE on both
TOM.EMPLOYEES and MARY.EMPLOYEES
TOM needs DELETE on JOE.EMPLOYEES and JOE needs DELETE on
MARY.EMPLOYEES (*)
JOE does not need any object privileges, but TOM needs DELETE on
MARY.EMPLOYEES
TOM needs DELETE on MARY.EMPLOYEES and JOE needs EXECUTE on
TOM.UPD_TRIGG
46. With which kind of trigger can the :OLD and :NEW qualifiers be used?
DDL triggers
Database Event triggers
Statement triggers
Row triggers (*)
AFTER triggers
True
False (*)
48. Examine the following trigger. It should raise an application error if a user tries to update
an employees last name. It should allow updates to all other columns of the EMPLOYEES
table. What should be coded at line A?
49. What is the event that will cause the trigger on the emp_details view below to fire?
CREATE OR REPLACE TRIGGER new_emp_dept
INSTEAD OF INSERT ON emp_details
BEGIN
INSERT INTO new_emps
VALUES (:NEW.employee_id, :NEW.last_name,
:NEW.salary, :NEW.department_id);
new_depts
SET dept_sal = dept_sal + :NEW.salary
WHERE department_id = :NEW.department_id;
END;
50. What is wrong with the following code example for a compound trigger?
CREATE OR REPLACE TRIGGER log_emps
FOR UPDATE OF salary ON employees
COMPOUND TRIGGER
TYPE t_log_emp IS TABLE OF log_table%ROWTYPE
INDEX BY BINARY_INTEGER;
log_emp_tab t_log_emp;
AFTER EACH ROW IS
BEGIN
some action
END AFTER EACH ROW;
AFTER STATEMENT IS
BEGIN
some action
END AFTER STATEMENT;
END log_emps;
The order of the timing statements is reversed. (*)
The declaration section is missing the DECLARE keyword.
The triggering event FOR UPDATE is not allowed.
The COMPOUND TRIGGER statement is missing IS.
There is nothing wrong with this example.
1. What is the correct format to declare a variable using the following emp_pkg package
composite data type? TYPE emprec_type IS TABLE OF employees%ROWTYPE INDEX
BY BINARY_INTEGER;
emp_pkg.emprec_type;
emprec_type.emp_pkg;
v_emp_table emprec_type.emp_pkg;
v_emp_table emp_pkg.emprec_type; (*)
None of the above
4. Functions called from a SQL query or DML statement must not end the current
transaction, or create or roll back to a savepoint. True or False?
True (*)
False
5. Package TAXPACK declares a global variable G_TAXRATE NUMBER(2,2). The value
of the tax rate is stored in table TAXTAB in the database. You want to read this value
automatically into G_TAXRATE each time a user session makes its first call to TAXPACK.
How would you do this?
Add a private function to the package body of TAXPACK, and invoke the function from the
user session.
6. Package NEWPACK contains several procedures and functions, including private function
PRIVFUNC. From where can PRIVFUNC be invoked? (Choose two.)
7. We need to declare a package variable named MYVAR, which can be referenced by any
subprogram in the package but can NOT be referenced from outside the package. In the
following code, where should MYVAR be declared?
CREATE OR REPLACE PACKAGE varpack IS
Point A
END varpack;
CREATE OR REPLACE PACKAGE BODY varpack IS
Point B
PROCEDURE varproc IS
Point C
BEGIN
END varproc;
PROCEDURE
Point D
END varpack;
Point A
Point B (*)
Point C
Point D
Point B or Point C, they will both work
The package body of TAXPACK also includes a function called TAXFUNC. Which one of
the following statements is NOT true?
The packaage will not compile because you cannot declare a cursor in the specification.
(*)
9. A package contains both public and private subprograms. Which one of the following
statements is true?
10. In a package, public components are declared in the specification but private components
are not. True or False?
True (*)
False
11. Which of the following statements about packages is NOT true ?
Which of the following will correctly invoke the package subprograms? (Choose two.)
mypack.myfunc(22-JAN-07);
mypack.myproc(35);
(*)
v_num := mypack.myproc(22);
13. Every subprogram which has been declared in a package specification must also be
included in the package body. Triue or False?
True (*)
False
14. Which of the following are good reasons for creating and using Packages?
Related procedures, functions and variables can be grouped together as a single unit
We can recompile the package body without having to recompile the specification
We can create packages without needing any system privileges
We can declare INDEX BY tables and use them as parameters
A and B
A, B and C
A and C
A, B and D (*)
A, B, C and D
UTL_FILE.CREATE(FILESDIR,EMP_REPORT.TXT);
UTL_FILE.FOPEN(C:\NEWFILES\EMP_REPORT.TXT,w);
UTL_FILE.FOPEN(FILESDIR,EMP_REPORT.TXT,w); (*)
UTL_FILE.OPEN(FILESDIR,EMP_REPORT.TXT,c);
I do like to be
beside the seaside
I do like
to be
beside the seaside
I do like to be
I do liketo be
(*)
17. The UTL_FILE package can be used to create binary files such as JPEGs as well as text
files. True or False?
True
False (*)
18. Why is it better to use DBMS_OUTPUT only in anonymous blocks, not inside stored
subprograms such as procedures?
19. When a user session changes the value of a package variable, the new value can
immediately be seen by other sessions. True or False?
True
False (*)
20. A cursor is declared in a package specification. User SIOBHAN opens the cursor and
fetches the first three rows from the cursors active set, but does not close the cursor.
User FRED now connects to the database. FRED can immediately fetch the next three rows
without opening the cursor. True or False?
True
False (*)
21. MARY wants HENRY to be able to query her EMPLOYEES table. Mary executes the
following code:
DECLARE
v_grant_stmt VARCHAR2(50);
BEGIN
v_grant_stmt := GRANT SELECT ON employees TO henry;
DBMS_SQL.EXECUTE(v_grant_stmt);
END;
True
False (*)
22. A SQL statement can pass through several stages. Which of the following is NOT one of
these stages?
BIND
FETCH
PARSE
RETURN (*)
EXECUTE
23. You want to create a function which drops a table. You write the following code:
CREATE OR REPLACE FUNCTION droptab
(p_tab_name IN VARCHAR2)
RETURN BOOLEAN IS
BEGIN
DROP TABLE p_tab_name;
RETURN TRUE;
EXCEPTION
WHEN OTHERS THEN RETURN FALSE;
END;
25. FORALL can be used with any DML statement. True or False?
True (*)
False
26. Deterministic means the function will always return the same output return value for any
given set of input argument values. True or False?
True (*)
False
27. 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;
Position A
Position B
Position C (*)
29. What is the event that will cause the trigger on the emp_details view below to fire?
CREATE OR REPLACE TRIGGER new_emp_dept
INSTEAD OF INSERT ON emp_details
BEGIN
INSERT INTO new_emps
VALUES (:NEW.employee_id, :NEW.last_name,
:NEW.salary, :NEW.department_id);
new_depts
SET dept_sal = dept_sal + :NEW.salary
WHERE department_id = :NEW.department_id;
END;
An attempt to update salary column on the new_depts table
A new employee is added to the emp_details table
A procedure calls the new_emp_dept trigger.
An attempt to add a row in the emp_details view (*)
An attempt to add a row in the new_depts table.
30. Examine the following code. To create a row trigger, what code should be included at
Line A?
CREATE TRIGGER dept_trigg
AFTER UPDATE OR DELETE ON departments
Line A
BEGIN
31. INSTEAD OF triggers are always row triggers, even if FOR EACH ROW is omitted.
True or False?
True (*)
False
True
False (*)
33. Which of the following can NOT be coded in the body of a DML trigger? (Choose two.)
IF DELETING THEN
IF SELECTING THEN (*)
IF INSERTING THEN
IF UPDATING (JOB_ID) THEN
IF OTHERS THEN (*)
34. Which dictionary view shows the detailed code of a trigger body?
USER_SOURCE
USER_TRIGGERS (*)
USER_OBJECTS
USER_DML_TRIGGERS
USER_SUBPROGRAMS
35. After the following SQL statement is executed, all the triggers on the DEPARTMENTS
table will no longer fire, but will remain in the database. True or False?
ALTER TABLE departments DISABLE ALL TRIGGERS;
True (*)
False
36. Which of the following will remove a trigger in your schema named EMP_TRIGG from
the database?
37. You need to create a trigger that will fire whenever an employees salary or job_id is
updated, but not when any other column of the EMPLOYEES table is updated. Which of the
following is the correct syntax to do this?
39. There are five employees in department 50. The following trigger is created:
CREATE TRIGGER upd_emp
AFTER UPDATE ON employees
BEGIN
INSERT INTO audit_table VALUES (USER, SYSDATE);
END;
One (*)
Two
Five
Six
None of the above
41. What type of database object would you create to write an auditing record automatically
every time a user connects to the database?
A procedure
A complex view
A trigger (*)
A function
A package
42. Which of the following are NOT stored inside the database? (Choose two.)
43. You can code COMMIT and ROLLBACK statements in a trigger body. True or False?
True
False (*)
44. A business rule states that an employees salary cannot be greater than 99,999.99 or less
than 0. The best way to enforce this rule is by using:
pack1.packproc(25); (*)
SELECT func1(100) FROM dual;
trigg1;
IF pack1.packfunc(40) THEN
46. You can use a trigger to prevent rows from being deleted from the EMPLOYEES table
on Mondays. True or False?
True (*)
False
47. You want to prevent any objects in your schema from being altered or dropped. You
decide to create the following trigger:
CREATE TRIGGER stop_ad_trigg
Line A
BEGIN
RAISE_APPLICATION_ERROR(-20203,Invalid Operation);
END;
48. A trigger automatically inserts a row into a logging table every time a users session
receives this error message:
ORA-00942: table or view does not exist
What kind of trigger is this?
A row trigger
A statement trigger
A database event trigger (*)
A DDL trigger
An AFTER trigger