Section 9

1. Every subprogram which has been declared in a package Mark for

specification must also be included in the package body. Triue or False? Review (1) Points True (*) False
Correct

2. Which one of the following can NOT be part of a Package ? Review (1) Points Procedures Explicit cursors Triggers (*) Functions Global variables

Mark for

Correct 3. Which part of a package must be created first, the specification or the body?

Mark for Review (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.
Correct 4. Package MYPACK contains procedure MYPROC. You can see which parameters MYPROC uses by executing: DESCRIBE mypack.myproc. True or False?

Mark for Review (1) Points

True False (*)
Correct 5. Examine the following code: CREATE OR REPLACE PACKAGE emppack IS PROCEDURE upd_emp (p_empno IN NUMBER, p_salary IN NUMBER); END emppack; CREATE OR REPLACE PACKAGE BODY emppack IS -- Line A PROCEDURE upd_emp (p_empno IN NUMBER, p_salary IN NUMBER) IS BEGIN IF NOT sal_ok(p_salary) THEN RAISE_APPLICATION_ERROR(-20201,'Invalid salary'); END IF; END upd_emp; FUNCTION sal_ok(pf_salary NUMBER) RETURN BOOLEAN IS BEGIN IF pf_salary > 50000 THEN RETURN FALSE; ELSE RETURN TRUE; END IF; END sal_ok; END emppack;

What must be coded at Line A for this package to compile successfully? Mark for Review (1) Points 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
Correct 6. Which two of these declarations cannot be in the same package specification?

1. PROCEDURE myproc (p1 NUMBER, p2 VARCHAR2);

2. PROCEDURE myproc (p1 VARCHAR2, p2 NUMBER); 3. PROCEDURE myproc (p1 NUMBER, p2 CHAR); 4. PROCEDURE myproc (p1 NUMBER); Mark for Review (1) Points 1 and 2 1 and 3 (*) 2 and 3 3 and 4 1 and 4
Correct 7. We never need to use a forward declaration when invoking a public

subprogram. True or False? (1) Points True (*) False

Mark for Review

Correct 8. 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.) Mark for Review (1) Points (Choose all correct answers) ol_pack.subprog('Jane',30); ol_pack.subprog(param1=>'Jane',param2=>30); (*)

.. Why will this procedure not compile successfully? Mark for Review (1) Points Because you can never drop a table from inside a function Because the PL/SQL compiler cannot check if the argument of p_tab_name is a valid table-name (*) Because you do not have the privilege needed to drop a table . EXCEPTION WHEN OTHERS THEN RETURN FALSE. 9. (*) Incorrect. You write the following code: CREATE OR REPLACE FUNCTION droptab (p_tab_name IN VARCHAR2) RETURN BOOLEAN IS BEGIN DROP TABLE p_tab_name. Refer to Section 9. v_date := ol_pack.v_number := ol_pack.subprog('Jane'. 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 (Choose all correct answers) DELETE SAVEPOINT ALTER (*) SELECT .30).subprog(p1=>'Jane').. You want to create a function which drops a table. RETURN TRUE. END. FOR UPDATE NOWAIT GRANT (*) Correct 10..

view_name. Examine the following code: CREATE OR REPLACE PROCEDURE myproc IS CURSOR c_curs IS SELECT view_name FROM user_views. The procedure will raise an exception because one of the views is a complex view. Correct . The procedure will raise an exception because Dynamic SQL can drop tables but cannot drop views.Because you cannot use RETURN in the exception section Correct Section 9 11. What will happen when this procedure is invoked? Mark for Review (1) Points All views in the user's schema will be dropped. END. (*) The procedure will not compile successfully because the syntax of EXECUTE IMMEDIATE is incorrect. Which of the Mark for Review following is NOT one of these stages? (1) Points BIND FETCH PARSE RETURN (*) EXECUTE Correct 12. BEGIN FOR v_curs_rec IN c_curs LOOP EXECUTE IMMEDIATE 'DROP VIEW ' || v_curs_rec. A SQL statement can pass through several stages. END LOOP.

they will both work Correct 14. CREATE OR REPLACE PACKAGE BODY varpack IS -. The package body of TAXPACK also includes a function called TAXFUNC. where should MYVAR be declared? CREATE OR REPLACE PACKAGE varpack IS -. which can be referenced by any subprogram in the package but can NOT be referenced from outside the package. END mypack. Which one of the following statements is NOT true? .13.Point A END varpack. PROCEDURE . PROCEDURE taxproc..Point B PROCEDURE varproc IS -. Mark for Review (1) Points Point A Point B (*) Point C Point D Point B or Point C. We need to declare a package variable named MYVAR. In the following code..Point C BEGIN END varproc. -. Examine the following package specification: CREATE OR REPLACE PACKAGE taxpack IS CURSOR empcurs IS SELECT * FROM employees.Point D END varpack.

taxproc. but the private subprograms are loaded into memory one at a time as they are invoked.Mark for Review (1) Points The procedure can be invoked by: BEGIN taxpack. (*) If three users invoke three different subprograms in the package. In a package. The whole package is loaded into memory when the first call is made to any subprogram in the package. A package contains both public and private subprograms. there will be three copies of the code in memory. The packaage will not compile because you cannot declare a cursor in the specification. public components are declared in the specification but private components are not. Correct 16. END. (*) TAXPROC is a public procedure and TAXFUNC is a private function TAXPROC can invoke TAXFUNC if TAXPROC is coded before TAXFUNC TAXPROC can open the cursor Correct 15. Which one of the following statements is true? Mark for Review (1) Points Each subprogram is loaded into memory when it is first invoked. True or False? (1) Points True (*) False Correct Mark for Review . The public subprograms are all loaded into memory at the same time.

Both the specification and the body will be dropped. The specification will be dropped but the body will be retained.17. Package OLDPACK is in your schema. What will be displayed by the following query? SELECT COUNT(*) FROM ALL_OBJECTS WHERE object_type LIKE 'PACK%' AND owner <> USER. each having a specification and a body. both the specification and the body must be recompiled. Mark for Review (1) Points 14 7 3 6 (*) 0 Correct 18. (*) The statement will fail because you must drop the body before you can drop the specification. Your schema contains four packages. You have also been granted privileges to access three packages (and their bodies) in other users' schemas. Correct 19. Mark for Review (1) Points The body will be dropped but the specification will be retained. True or False? (1) Points Mark for Review . What will happen when the following statement is executed? DROP PACKAGE oldpack. When a change is made to the detailed code of a public procedure in a package (but not to the procedure's name or parameters).

The DBMS_OUTPUT.True False (*) Incorrect. DBMS_OUTPUT.PUT_LINE('to be'). END. True or False? (1) Points True (*) False Correct Section 9 Mark for Review 21.PUT procedure places text in a buffer but does not display the contents of the buffer.PUT('beside the seaside'). . What will be displayed when the following code is executed? BEGIN DBMS_OUTPUT. DBMS_OUTPUT. 20. Refer to Section 9. True or False? (1) Points True False (*) Correct 22.PUT('I do like'). The UTL_FILE package can be used to create binary files such as Mark for Review JPEGs as well as text files. Which of the following exceptions can be raised ONLY when using the UTL_FILE package? (Choose two) Mark for Review (1) Points (Choose all correct answers) INVALID_PATH (*) NO_DATA_FOUND VALUE_ERROR READ_ERROR (*) E_MYEXCEP Correct 23.

Mark for Review (1) Points 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 (*) I do like to be beside the seaside Incorrect.g_myvar := 45. User HAZEL now connects to the database. Refer to Section 9. Package MULTIPACK declares the following global variable: g_myvar NUMBER. 24. Both users immediately execute: BEGIN DBMS_OUTPUT. Mark for Review User DICK executes the following: multipack.PUT_LINE(multipack. When a user session changes the value of a package variable. True or False? (1) Points True False (*) Correct 25. What values will Dick and Hazel see? Mark for Review (1) Points Dick: 45. END.g_myvar). the new value can immediately be seen by other sessions. Hazel: 45 .

'Updating last name not allowed'). Hazel: null (*) Dick: 0. Refer to Section 9. It should allow updates to all other columns of the EMPLOYEES table. ... Hazel: 0 Both queries will fail because the syntax of DBMS_OUTPUT. END. Section 10 26. what code should be included at Line A? CREATE TRIGGER dept_trigg AFTER UPDATE OR DELETE ON departments -. What should be coded at line A? CREATE TRIGGER stop_ln_trigg BEFORE UPDATE ON employees BEGIN -. Hazel: 0 Dick: 45. Examine the following code.PUT_LINE is incorrect Incorrect. END IF.Line A RAISE_APPLICATION_ERROR(-20201.Line A BEGIN . It should raise an application error if a user tries to update an employee's last name.Dick: 45. To create a row trigger. Mark for Review (1) Points IF UPDATING LAST_NAME THEN IF UPDATING('LAST_NAME') THEN (*) IF UPDATE('LAST_NAME') THEN IF UPDATING THEN Correct 27. Examine the following trigger.

my_object_name can be the name of a table. Which of the following can NOT be coded in the body of a DML trigger? (Choose two..) Mark for Review (1) Points (Choose all correct answers) IF DELETING THEN IF SELECTING THEN (*) IF INSERTING THEN IF UPDATING ('JOB_ID') THEN IF OTHERS THEN (*) Correct 29.Mark for Review (1) Points AFTER EACH ROW FOR EVERY ROW FOR EACH ROW (*) ON EACH ROW ON EVERY ROW Correct 28. True or False? Mark for Review (1) Points True False (*) . In the following code: CREATE TRIGGER mytrigg INSTEAD OF INSERT OR UPDATE ON my_object_name FOR EACH ROW BEGIN ..

Correct Section 10 31. JOE creates the following trigger: CREATE TRIGGER upd_trigg AFTER DELETE ON joe. MARY and JOE's schemas each contain an EMPLOYEES table.employees FOR EACH ROW BEGIN DELETE FROM mary.EMPLOYEES and MARY. The table is dropped and the trigger is disabled. A third user TOM needs to delete rows from JOE's EMPLOYEES table.Correct 30.EMPLOYEES and JOE needs DELETE on MARY.. What object privileges will TOM and JOE need? Mark for Review (1) Points TOM does not need any object privileges. Both the table and the trigger are dropped. END. but JOE needs DELETE on both TOM.locations BEGIN .employees WHERE employee_id = :OLD. AYSEGUL now tries to drop the LOCATIONS table.employee_id.. What happens? Mark for Review (1) Points An error message is displayed because you cannot drop a table that is associated with a trigger. User AYSEGUL successfully creates the following trigger: CREATE TRIGGER loc_trigg BEFORE UPDATE ON aysegul.EMPLOYEES TOM needs DELETE on JOE. (*) None of the above. The trigger is dropped but the table is not dropped.EMPLOYEES (*) .

but TOM needs DELETE on MARY.JOE does not need any object privileges. DROP TRIGGER emp_trigg. (*) . Mark for Review ALTER TRIGGER emp_trigg DISABLE. UPDATE employees SET job_id = 'IT_PROG' WHERE employee_id = :OLD.EMPLOYEES TOM needs DELETE on MARY. Examine the following code: CREATE TRIGGER emp_trigg AFTER UPDATE OF salary ON employees FOR EACH ROW DECLARE v_count NUMBER. BEGIN -.Line A END. SELECT count(*) INTO v_count FROM employees.UPD_TRIGG Correct 32. None of the above Correct 33.EMPLOYEES and JOE needs EXECUTE on TOM. (*) REMOVE TRIGGER emp_trigg. Which of the following will remove a trigger in your schema named EMP_TRIGG from the database? (1) Points DROP emp_trigg TRIGGER.employee_id. Which of the following statements is NOT allowed at Line A? Mark for Review (1) Points SELECT count(*) INTO v_count FROM departments.

END. Which of the following statements could cause a DDL trigger to fire? Mark for Review (1) Points DROP TABLE employees.2)).DBMS_OUTPUT.Line A BEGIN RAISE_APPLICATION_ERROR(-20203. TRUNCATE TABLE locations. You want to prevent any objects in your schema from being altered or dropped. None. All of the above (*) Correct 35. All of the above are allowed. DROP ON SCHEMA AFTER ALTER. DROP ON SCHEMA . Correct 34. You decide to create the following trigger: CREATE TRIGGER stop_ad_trigg -. What should you code at Line A ? Mark for Review (1) Points AFTER ALTER OR DROP ON SCHEMA INSTEAD OF ALTER OR DROP ON SCHEMA BEFORE ALTER OR DROP ON SCHEMA (*) BEFORE ALTER. CREATE TABLE newemp AS SELECT * FROM employees. ALTER TABLE departments ADD (budget NUMBER(8.PUT_LINE('A salary was updated').'Invalid Operation').

Refer to Section 10. you must not code BEGIN When using CALL..) Mark for Review (1) Points (Choose all correct answers) TABLE SCHEMA (*) USER DATABASE (*) TABLE employees . Examine this code: CREATE TRIGGER new_trigg AFTER CREATE ON reserved_word BEGIN . The CALL statement must not end with a semicolon (.Incorrect. What is wrong with the following code? CREATE TRIGGER call_trigg AFTER LOGOFF ON SCHEMA BEGIN CALL drop_proc. Which of the following can be used in place of reserved_word? (Choose two. you must not code END.. 36. Mark for Review (1) Points You cannot code an AFTER LOGOFF trigger When using CALL.) All of the above (*) Correct 37. END.

What should the DBA code at Line A ? Mark for Review (1) Points AFTER ERROR ON DATABASE AFTER SERVER ERROR ON DATABASE AFTER SERVERERROR ON SCHEMA AFTER SERVERERROR ON DATABASE (*) AFTER ORACLE ERROR ON SCHEMA Correct 40. 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 Mark for Review Correct 39. The database administrator wants to write a log record every time an Oracle Server error occurs in any user's session. END. The DBA creates the following trigger: CREATE TRIGGER log_errs_trigg -. Examine the following code: .Line A BEGIN INSERT INTO errlog_table VALUES (..).Correct 38..

SYSDATE). END.CREATE TRIGGER emp_trigg -.DELETE) ON employees. Which of the following can NOT be coded at Line A? Mark for Review (1) Points BEFORE UPDATE ON employees AFTER INSERT OR DELETE ON employees AFTER SELECT ON employees (*) BEFORE DELETE ON employees AFTER UPDATE OF last_name ON employees Correct Section 10 41. departments DML triggers must be row triggers. so FOR EACH ROW is missing The second line should be: BEFORE UPDATE OR DELETE ON employees OR departments Correct .Line A BEGIN INSERT INTO log_table VALUES (USER. What is wrong with the following code? CREATE OR REPLACE TRIGGER emp_dept_trigg BEFORE UPDATE OR DELETE ON employees. departments BEGIN Mark for Review (1) Points One trigger can be associated with only one table (*) The second line should be: BEFORE (UPDATE.

) Mark for Review (1) Points (Choose all correct answers) Where possible. job_id) BEGIN .. but not when any other column of the EMPLOYEES table is updated. You need to create a trigger that will fire whenever an employee's salary or job_id is updated...42. Which of the following is the correct syntax to do this? (1) Points CREATE TRIGGER emp_upd_trigg AFTER UPDATE ON employees (salary. Mark for Review (1) Points True False (*) Correct 44. job_id) ON employees BEGIN .. END.. use a trigger to enforce a foreign key constraint. job_id ON employees BEGIN . Use triggers to override privilege checking and view other users' private tables. CREATE TRIGGER emp_upd_trigg AFTER UPDATE OF salary OR job_id ON employees BEGIN . (*) CREATE TRIGGER emp_upd_trigg AFTER UPDATE OF (salary..'Deleting salary is not allowed'). Correct 43.. The following code will successfully create emp_trigg: True or False? Mark for Review CREATE OR REPLACE TRIGGER emp_trigg BEFORE DELETE OF salary ON employees BEGIN RAISE_APPLICATION_ERROR(-20202.. . CREATE TRIGGER emp_upd_trigg AFTER UPDATE OF salary. Which of the following are good guidelines to follow when creating a database trigger? (Choose two.

A trigger can be created in the database or within an application. True or False? Mark for Review (1) Points True (*) False Correct 47. (*) Use triggers to prevent unauthorized users from SELECTing confidential data.Do not use a trigger to replace or duplicate something which the Oracle Server does automatically. You can code COMMIT and ROLLBACK statements in a trigger body. What type of database object would you create to write an auditing record automatically every time a user connects to the database? (1) Points A procedure A complex view A trigger (*) A function A package Correct Mark for Review . True or False? (1) Points True False (*) Mark for Review Correct 46. (*) Correct 45. Do not create a trigger that automatically fires another trigger.

99 or less than 0. A PL/SQL subprogram that executes automatically whenever an associated database event occurs. A trigger can be a public subprogram within a PL/SQL package. True or False? Mark for Review (1) Points True False (*) Correct 50. (*) A PL/SQL subprogram that always returns exactly one value. Correct 49. A PL/SQL subprogram that inserts rows into a logging table. Which of the following best describes a database trigger? Mark for Review (1) Points A subprogram that checks whether a user has typed the correct password to log on to the database. The best way to enforce this rule is by using: Review (1) Points A datatype of NUMBER(7. A business rule states that an employee's salary cannot be greater than 99.48.2) for the SALARY column A database trigger A check constraint (*) An application trigger A view Correct Mark for . A subprogram that is invoked explicitly by the calling application.999.

PUT_LINE('A salary was updated').Line A END.employee_id. The database administrator wants to write a log record every time an Oracle Server error occurs in any user's session. ALTER TABLE departments ADD (budget NUMBER(8. UPDATE employees SET job_id = 'IT_PROG' WHERE employee_id = :OLD. Correct 2. (*) Mark for DBMS_OUTPUT. Which of the following statements is NOT allowed at Line A? Review (1) Points SELECT count(*) INTO v_count FROM departments.2)). Examine the following code: CREATE TRIGGER emp_trigg AFTER UPDATE OF salary ON employees FOR EACH ROW DECLARE v_count NUMBER. TRUNCATE TABLE locations. All of the above (*) Correct 3. All of the above are allowed. None. CREATE TABLE newemp AS SELECT * FROM employees. The DBA creates the following trigger: . SELECT count(*) INTO v_count FROM employees.Mid Term Exam Semester 2 1. BEGIN -. Which of the following statements could cause a DDL trigger to fire? Mark for Review (1) Points DROP TABLE employees.

You want to prevent any objects in your schema from being altered or dropped. Refer to Section 10. 5.CREATE TRIGGER log_errs_trigg -. Which kinds of trigger can cause a mutating table problem? (Choose two.) Mark for Review (1) Points (Choose all correct answers) BEFORE UPDATE row triggers (*) DDL triggers . DROP ON SCHEMA AFTER ALTER.'Invalid Operation'). What should the DBA code at Line A ? Mark for Review (1) Points AFTER ERROR ON DATABASE AFTER SERVER ERROR ON DATABASE AFTER SERVERERROR ON SCHEMA AFTER SERVERERROR ON DATABASE (*) AFTER ORACLE ERROR ON SCHEMA Correct 4. END. You decide to create the following trigger: CREATE TRIGGER stop_ad_trigg -.Line A BEGIN RAISE_APPLICATION_ERROR(-20203..). DROP ON SCHEMA Incorrect.Line A BEGIN INSERT INTO errlog_table VALUES (. What should you code at Line A ? (1) Points Mark for Review AFTER ALTER OR DROP ON SCHEMA INSTEAD OF ALTER OR DROP ON SCHEMA BEFORE ALTER OR DROP ON SCHEMA (*) BEFORE ALTER. END..

.AFTER DELETE row triggers (*) Database Event triggers INSTEAD OF triggers Incorrect...) for Review (1) Points (Choose all correct answers) AFTER LOGOFF ON SCHEMA (*) AFTER LOGON ON SCHEMA BEFORE LOGOFF ON SCHEMA BEFORE DISCONNECT ON SCHEMA (*) AFTER SERVERERROR ON SCHEMA Correct Mark .Line A BEGIN . Which of the following are NOT valid at Line A ? (Choose two. Examine this code: CREATE TRIGGER de_trigg -.) Mark for Review (1) Points (Choose all correct answers) TABLE SCHEMA (*) USER DATABASE (*) TABLE employees Correct 7.6.. Examine this code: CREATE TRIGGER new_trigg AFTER CREATE ON reserved_word BEGIN . Refer to Section 10. Which of the following can be used in place of reserved_word? (Choose two.

10.. After the following SQL statement is executed. True or False? ALTER TABLE departments DISABLE ALL TRIGGERS.8. (*) Both the table and the trigger are dropped. ALTER TABLE departments DISABLE TRIGGERS. but will remain in the database. . all the triggers on the DEPARTMENTS table will no longer fire. The table is dropped and the trigger is disabled. You need to disable all triggers that are associated with DML statements on the DEPARTMENTS table. DISABLE ALL TRIGGERS ON departments..locations BEGIN . The trigger is dropped but the table is not dropped. Correct 9. Refer to Section 10. User AYSEGUL successfully creates the following trigger: CREATE TRIGGER loc_trigg BEFORE UPDATE ON aysegul. ALTER TRIGGER DISABLE ALL ON departments. What happens? Review (1) Points Mark for An error message is displayed because you cannot drop a table that is associated with a trigger. Which of the following commands should you use? Mark for Review (1) Points (*) ALTER TABLE departments DISABLE ALL TRIGGERS. ALTER TABLE departments DROP ALL TRIGGERS. (1) Points True (*) False Mark for Review Incorrect. AYSEGUL now tries to drop the LOCATIONS table.

END. Which of the following SQL statements can be included in a PL/SQL block only by using Dynamic SQL? (Choose two. Correct11.None of the above.) Mark for Review (1) Points Mark for Review All views in the user's schema will be (Choose all correct answers) .view_name. Examine the following code: CREATE OR REPLACE PROCEDURE myproc IS CURSOR c_curs IS SELECT view_name FROM user_views. Refer to Section 9. A SQL statement can pass through several stages. 13. BEGIN FOR v_curs_rec IN c_curs LOOP EXECUTE IMMEDIATE 'DROP VIEW ' || v_curs_rec. (*) The procedure will not compile successfully because the syntax of EXECUTE IMMEDIATE is incorrect. Which of the following is NOT one of these stages? Mark for Review (1) Points BIND FETCH PARSE RETURN (*) EXECUTE Correct 12. END LOOP. What will happen when this procedure is invoked? (1) Points dropped. Incorrect. 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.

True or False? Mark for Review (1) Points True False (*) Incorrect. Mary has successfully granted the privilege to Henry. Refer to Section 9. Hazel: null (*) . Hazel: 45 Dick: 45.. MARY wants HENRY to be able to query her EMPLOYEES table.. Both users immediately execute: BEGIN DBMS_OUTPUT. What values will Dick and Hazel see? (1) Points Mark for Review Dick: 45. Hazel: 0 Dick: 45. User HAZEL now connects to the database.EXECUTE(v_grant_stmt). END. Package MULTIPACK declares the following global variable: g_myvar NUMBER.PUT_LINE(multipack. v_grant_stmt := 'GRANT SELECT ON employees TO henry'. FOR UPDATE NOWAIT GRANT (*) Correct 14. BEGIN END.g_myvar := 45.. 15.DELETE SAVEPOINT ALTER (*) SELECT . DBMS_SQL.g_myvar). User DICK executes the following: multipack. Mary executes the following code: DECLARE v_grant_stmt VARCHAR2(50)..

line 3 curspack. The first 10 rows will be fetched. An error will occur at line 4. It is executed automatically every time any global variable in the package is referenced. FETCHPROC fetches 5 rows from the cursor's active set. -.line 1 curspack. -. then the first 5 rows will be fetched again. -. -. -. Which of the following statements about a package initialization block is true? Mark for Review (1) Points It cannot contain any SQL statements. The package contains three public procedures: OPENPROC opens the cursor. Hazel: 0 Both queries will fail because the syntax of DBMS_OUTPUT.line 2 curspack.openproc.fetchproc. -.line 6 Mark for Review (1) Points The first 15 rows will be fetched. What will happen when a user session executes the following commands in the order shown? curspack.fetchproc. package body. An error will occur at line 2. It is an anonymous block in the package specification. Package CURSPACK declares a global cursor in the package specification. (*) Correct 17. CLOSEPROC closes the cursor.line 5 curspack.closeproc.line 4 curspack.PUT_LINE is incorrect Correct16.fetchproc.Dick: 0. (*) It is an anonymous block at the end of a It is a procedure in a package that must be invoked before the rest of the package can be used. Correct . The first 5 rows will be fetched three times.openproc.

p2 VARCHAR2). VARCHAR2. and invoke the function from the user session.2). NUMBER. Which two of these declarations cannot be in the same package specification? PROCEDURE myproc PROCEDURE myproc PROCEDURE myproc PROCEDURE myproc (1) Points (p1 (p1 (p1 (p1 NUMBER. A public function in a package is invoked from within a SQL statement. (*) Correct 20. NUMBER). True or False? Mark for Review (1) Points True False (*) Correct 19. You want to read this value automatically into G_TAXRATE each time a user session makes its first call to TAXPACK. The function's code can include a COMMIT statement.18.2) := SELECT tax_rate FROM taxtab. p2 CHAR). Add a package initialization block to the package body of TAXPACK. Mark for Review 1 and 2 1 and 3 (*) 2 and 3 3 and 4 . The value of the tax rate is stored in table TAXTAB in the database. Package TAXPACK declares a global variable G_TAXRATE NUMBER(2. p2 NUMBER). Add a private function to the package body of TAXPACK. How would you do this? Mark for Review (1) Points Declare the global variable as: g_taxrate NUMBER(2. Create a database trigger that includes the following code: SELECT tax_rate INTO taxpack.g_taxrate FROM taxtab.

1 and 4
Correct21. are NOT stored inside the database? (Choose two.) (1) Points

Which of the following Mark for Review

(Choose all correct answers) A PL/SQL package specification A database trigger An anonymous block (*) An application trigger (*) A sequence Incorrect. Refer to Section 10.
22. You can use a trigger to prevent rows from being deleted from the EMPLOYEES table on Mondays. True or False? Mark for Review

(1) Points

True (*) False
Correct 23. What type of database object would you create to write an auditing record automatically every time a user connects to the database? Mark for Review (1) Points

A procedure A complex view A trigger (*) A function A package
Correct 24. 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: Mark for Review

(1) Points A datatype of NUMBER(7,2) for the SALARY column A database trigger A check constraint (*) An application trigger A view
Correct 25. The following objects have been created in a user's schema: - a function FUNC1 - A package PACK1 which contains a public procedure PACKPROC and a private function PACKFUNC - a trigger TRIGG1.

The procedure and functions each accept a single IN parameter of type NUMBER, and the functions return BOOLEANs. Which of the following calls to these objects (from an anonymous block) are correct? (Choose two.) Mark for Review (1) Points (Choose all correct answers) pack1.packproc(25); (*) SELECT func1(100) FROM dual; trigg1; IF pack1.packfunc(40) THEN ... IF func1(75) THEN ... (*)
Correct26. You can code COMMIT and ROLLBACK statements in a trigger body. True or False? Mark for Review (1) Points

True False (*)
Correct 27. A trigger can be created in the database or within an application. True or False? Mark for Review

(1) Points

True (*) False
Correct 28. executing:

An Oracle directory called FILESDIR has been created by

CREATE OR REPLACE DIRECTORY filesdir AS 'C:\NEWFILES'; Which of the following will create a new text file called C:\NEWFILES\EMP_REPORT.TXT ? Mark for Review (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');
Correct 29. Why is it better to use DBMS_OUTPUT only in anonymous blocks, not inside stored subprograms such as procedures? Mark for Review (1) Points

Because DBMS_OUTPUT cannot be used inside procedures Because anonymous blocks display messages while the block is executing, while procedures do not display anything until their execution has finished Because DBMS_OUTPUT should be used only for testing and debugging PL/SQL code (*) Because DBMS_OUTPUT can raise a NO_DATA_FOUND exception if used inside a packaged procedure
Correct 30. Which of the following best describes the purpose of the UTL_FILE package? Mark for Review (1) Points

PUT('I do like'). END. Triue or False? Mark for Review (1) Points True (*) False Incorrect.PUT('beside the seaside'). 32.PUT_LINE('to be'). (*) It is used to find out how much free space is left on an operating system disk. DBMS_OUTPUT. Every subprogram which has been declared in a package specification must also be included in the package body. Mark for Review (1) Points 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 (*) I do like to be beside the seaside Incorrect. It is used to query CHAR and VARCHAR2 columns in tables. when the following code is executed? BEGIN What will be displayed DBMS_OUTPUT. Refer to Section 9.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. . Correct31. Refer to Section 9. DBMS_OUTPUT.

END IF.myproc(35). (*) IF NOT mypack. The following package specification has been created: CREATE OR REPLACE PACKAGE mypack IS FUNCTION myfunc(p_funcparam DATE) RETURN BOOLEAN.PUT_LINE('Message').myfunc(SYSDATE) THEN DBMS_OUTPUT. What is wrong with the following syntax for creating a package specification? . Procedures Explicit cursors Triggers (*) Functions Global variables Correct 35.myproc(22). Correct Which one of the following can NOT be part of a Package ? Mark for Review (1) Points 34.) Mark for Review (1) Points (Choose all correct answers) mypack.myfunc('22-JAN-07'). (*) myproc(40). PROCEDURE myproc(p_procparam IN NUMBER). mypack. Which of the following will correctly invoke the package subprograms? (Choose two. v_num := mypack.33. END mypack.

CREATE OR REPLACE PACKAGE mypack IS g_constant1 NUMBER(6) := 100. A package must contain at least one procedure. Nothing is wrong. this trigger will compile . Refer to Section 9. The second line should be: BEFORE DELETE OF locations You cannot use ROLLBACK inside a trigger. Mark for Review (1) Points END loc_trigg.36. Incorrect. (*) The first line should be: CREATE OR REPLACE PACKAGE SPECIFICATION mypack IS Nothing is wrong. You cannot use RAISE_APPLICATION_ERROR inside a trigger. What is wrong with the following code? CREATE OR REPLACE TRIGGER loc_trigg BEFORE DELETE ON locations BEGIN RAISE_APPLICATION_ERROR(-20201. (*) delete'). The last line should be: and execute successfully. Mark for Review (1) Points You cannot declare constants in the specification. this code contains no errors. END mypack. FUNCTION func2. END.'Invalid ROLLBACK. FUNCTION func1 (p_param1 IN VARCHAR2). The RETURN datatype of the functions must be specified.

Mark for Review (1) Points salary is not allowed'). What is wrong with the following code? CREATE OR REPLACE TRIGGER emp_dept_trigg BEFORE UPDATE OR DELETE ON employees.'Deleting END.Correct 37. True or False? Mark for Review (1) Points True (*) False Correct 39. so FOR EACH ROW is missing The second line should be: BEFORE UPDATE OR DELETE ON employees OR departments Incorrect. A DML statement trigger fires only once for each triggering DML statement.DELETE) ON employees. 38. . while a row trigger fires once for each row processed by the triggering statement. departments DML triggers must be row triggers. departments BEGIN Mark for Review (1) Points One trigger can be associated with only one table (*) The second line should be: BEFORE (UPDATE. Refer to Section 10. True or False? The following code will successfully create emp_trigg: CREATE OR REPLACE TRIGGER emp_trigg BEFORE DELETE OF salary ON employees BEGIN RAISE_APPLICATION_ERROR(-20202.

) Review (1) Points (Choose all correct answers) From an anonymous block From any procedure in NEWPACK (*) Mark for From any private function in another package From any function in NEWPACK (*) From any public procedure in another package Correct 42. (*) SELECT text FROM USER_SOURCE . Package NEWPACK contains several procedures and functions. SELECT text FROM USER_SOURCE WHERE name = 'DEPTPACK' AND type = 'PACKAGE BODY' ORDER BY line.True False (*) Incorrect. Refer to Section 10. 40. Which of the following will display the detailed code of the subprograms in package DEPTPACK in your schema ? Mark for Review (1) Points SELECT text FROM USER_SOURCE WHERE name = 'DEPTPACK' AND type = 'PACKAGE' ORDER BY line. including private function PRIVFUNC. True or False? Mark for Review (1) Points True (*) False Correct41. From where can PRIVFUNC be invoked? (Choose two. public components are declared in the specification but private components are not. In a package.

(1) Points Mark for Review The body will be dropped but the specification will be retained. SELECT text FROM USER_SOURCE WHERE name = 'DEPTPACK' AND type = 'BODY' ORDER BY line. each having a specification and a body. (*) The statement will fail because you must drop the body before you can drop the specification. The specification will be dropped but the body will be retained. True or False? Mark for Review (1) Points True False (*) Correct 45. Both the specification and the body will be dropped. What will be displayed by the following query? SELECT COUNT(*) FROM ALL_OBJECTS WHERE object_type LIKE 'PACK%' . Correct 44. Your schema contains four packages.WHERE object_name = 'DEPTPACK' AND object_type = 'PACKAGE BODY' ORDER BY line. Correct 43. When a change is made to the detailed code of a public procedure in a package (but not to the procedure's name or parameters). What will happen when the following statement is executed? DROP PACKAGE oldpack. Package OLDPACK is in your schema. both the specification and the body must be recompiled. You have also been granted privileges to access three packages (and their bodies) in other users' schemas.

.Line A BEGIN . We want to remove the specification (but not the body) of package BIGPACK from the database. DROP PACKAGE SPECIFICATION bigpack. With which kind of trigger can the :OLD and :NEW qualifiers be used? Mark for Review . Which of the following commands will do this? Mark for Review (1) Points DROP PACKAGE bigpack.AND owner <> USER. what code should be included at Line A? CREATE TRIGGER dept_trigg AFTER UPDATE OR DELETE ON departments -. (1) Points Mark for Review 14 7 3 6 (*) 0 Correct46. None of the above (*) Correct 47.. Mark for Review (1) Points AFTER EACH ROW FOR EVERY ROW FOR EACH ROW (*) ON EACH ROW ON EVERY ROW Correct 48. DROP PACKAGE bigpack SPECIFICATION. To create a row trigger. Examine the following code. DROP PACKAGE HEADER bigpack.

It should raise an application error if a user tries to update an employee's last name.. END IF. Examine the following trigger. my_object_name can be the name of a table. In the following code: CREATE TRIGGER mytrigg INSTEAD OF INSERT OR UPDATE ON my_object_name FOR EACH ROW BEGIN . True or False? Review (1) Points True False (*) Mark for Incorrect.(1) Points DDL triggers Database Event triggers Statement triggers Row triggers (*) AFTER triggers Correct 49. Refer to Section 10. What should be coded at line A? CREATE TRIGGER stop_ln_trigg BEFORE UPDATE ON employees BEGIN -.'Updating last name not allowed'). END. It should allow updates to all other columns of the EMPLOYEES table. Mark for Review (1) Points IF UPDATING LAST_NAME THEN IF UPDATING('LAST_NAME') THEN (*) IF UPDATE('LAST_NAME') THEN IF UPDATING THEN Correct .. 50.Line A RAISE_APPLICATION_ERROR(-20201.

Refer to Section 10.DELETE) ON employees. END. 3. 2. SYSDATE). so FOR EACH ROW is missing The second line should be: BEFORE UPDATE OR DELETE ON employees OR departments Incorrect. Which of the following can NOT be coded at Line A? Mark for Review (1) Points BEFORE UPDATE ON employees AFTER INSERT OR DELETE ON employees AFTER SELECT ON employees (*) BEFORE DELETE ON employees AFTER UPDATE OF last_name ON employees Incorrect. What is wrong with the following code? CREATE OR REPLACE TRIGGER emp_dept_trigg BEFORE UPDATE OR DELETE ON employees.Line A BEGIN INSERT INTO log_table VALUES (USER.Mid Term Exam Semester 2 1. departments DML triggers must be row triggers. Refer to Section 10. Examine the following code: CREATE TRIGGER emp_trigg -. but not when any other column of . departments BEGIN Mark for Review (1) Points One trigger can be associated with only one table (*) The second line should be: BEFORE (UPDATE. You need to create a trigger that will fire whenever an employee's salary or job_id is updated.

. job_id ON employees BEGIN . delete')... this trigger will compile and execute successfully.the EMPLOYEES table is updated. job_id) ON employees BEGIN . END.. The last line should be: You cannot use RAISE_APPLICATION_ERROR inside a trigger. CREATE TRIGGER emp_upd_trigg AFTER UPDATE OF salary OR job_id ON employees BEGIN .. CREATE TRIGGER emp_upd_trigg AFTER UPDATE OF salary. (*) Nothing is wrong.'Invalid ROLLBACK. 4.. Refer to Section 10. (*) CREATE TRIGGER emp_upd_trigg AFTER UPDATE OF (salary. The second line should be: BEFORE DELETE OF locations You cannot use ROLLBACK inside a trigger. Mark for Review (1) Points END loc_trigg.. Which of the following is the correct syntax to do this? Mark for Review (1) Points CREATE TRIGGER emp_upd_trigg AFTER UPDATE ON employees (salary... What is wrong with the following code? CREATE OR REPLACE TRIGGER loc_trigg BEFORE DELETE ON locations BEGIN RAISE_APPLICATION_ERROR(-20201. Incorrect. job_id) BEGIN .

B. .Incorrect. 5. PROCEDURE myproc(p_procparam IN NUMBER). (*) myproc(40).myfunc('22-JAN-07'). B and D (*) A. using Packages? Which of the following are good reasons for creating and Related procedures. mypack. Refer to Section 10. END mypack. The following package specification has been created: 6.PUT_LINE('Message'). CREATE OR REPLACE PACKAGE mypack IS FUNCTION myfunc(p_funcparam DATE) RETURN BOOLEAN. (*) IF NOT mypack.) Mark for Review (1) Points (Choose all correct answers) mypack. Refer to Section 9. 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 Mark for Review (1) Points A and B A. Which of the following will correctly invoke the package subprograms? (Choose two. C and D Incorrect.myfunc(SYSDATE) THEN DBMS_OUTPUT.myproc(35). END IF. B and C A and C A.

The body contains the detailed code of the subprograms. Refer to Section 9. 9. Correct 7. 8.) Mark for Review (1) Points (Choose all correct answers) DELETE SAVEPOINT ALTER (*) . Refer to Section 9. (*) Cursors can be declared in the specification. Which of the following SQL statements can be included in a PL/SQL block only by using Dynamic SQL? (Choose two. Which of the following statements about packages is NOT true ? Mark for Review (1) Points All procedures and functions must be declared in the specification. Variables can be declared in the body. Which one of the following can NOT be part of a Package Mark for Review (1) Points ? Procedures Explicit cursors Triggers (*) Functions Global variables Incorrect. Incorrect.v_num := mypack. The specification must be created before the body.myproc(22).

v_first_string := v_first_string || p_col_name. Which of the following is NOT one of these stages? Mark for Review (1) Points BIND FETCH . v_second_string VARCHAR2(6) := ' DATE)'. Line A END. (*) EXECUTE IMMEDIATE 'v_first_string' || p_col_name || 'v_second_string'.. Which of the following will work correctly when coded at line A? (Choose two. A SQL statement can pass through several stages.SELECT ... Incorrect. (*) EXECUTE v_first_string || p_col_name || v_second_string.. FOR UPDATE NOWAIT GRANT (*) Incorrect. The name of the new column is passed to the procedure as a parameter. BEGIN .. Refer to Section 9. Refer to Section 9.. EXECUTE IMMEDIATE v_first_string || p_col_name || v_second_string. 10.) Mark for Review (1) Points (Choose all correct answers) v_first_string || p_col_name || v_second_string. EXECUTE IMMEDIATE v_first_string || v_second_string. CREATE OR REPLACE PROCEDURE addcol (p_col_name IN VARCHAR2) IS v_first_string VARCHAR2(100) := 'ALTER TABLE EMPLOYEES ADD ('.11. The following procedure adds a column of datatype DATE to the EMPLOYEES table.

True or False? Mark for Review (1) Points Mark for Review Because you can never drop a table from True False (*) Incorrect. EXCEPTION WHEN OTHERS THEN RETURN FALSE. You want to create a function which drops a table. both the specification and the body must be recompiled. Why will this procedure not compile successfully? (1) Points inside a function Because the PL/SQL compiler cannot check if the argument of p_tab_name is a valid table-name (*) Because you do not have the privilege needed to drop a table Because you cannot use RETURN in the exception section Correct 13. You write the following code: CREATE OR REPLACE FUNCTION droptab (p_tab_name IN VARCHAR2) RETURN BOOLEAN IS BEGIN DROP TABLE p_tab_name. When a change is made to the detailed code of a public procedure in a package (but not to the procedure's name or parameters).PARSE RETURN (*) EXECUTE Incorrect. END. Refer to Section 9. RETURN TRUE. Refer to Section 9. 12. .

Package NEWPACK contains several procedures and functions. Correct . DROP PACKAGE HEADER bigpack. We want to remove the specification (but not the body) of package BIGPACK from the database. Both the specification and the body will be dropped. DROP PACKAGE bigpack SPECIFICATION.14. Package OLDPACK is in your schema. including private function PRIVFUNC.16. Refer to Section 9.) Mark for Review (1) Points (Choose all correct answers) From an anonymous block From any procedure in NEWPACK (*) From any private function in another package From any function in NEWPACK (*) From any public procedure in another package Correct 15. DROP PACKAGE SPECIFICATION bigpack. None of the above (*) Incorrect. What will happen when the following statement is executed? DROP PACKAGE oldpack. The specification will be dropped but the body will be retained. Which of the following commands will do this? Mark for Review (1) Points DROP PACKAGE bigpack. From where can PRIVFUNC be invoked? (Choose two. (1) Points Mark for Review The body will be dropped but the specification will be retained. (*) The statement will fail because you must drop the body before you can drop the specification.

PROCEDURE taxproc. (*) a private function coded before TAXFUNC TAXPROC is a public procedure and TAXFUNC is TAXPROC can invoke TAXFUNC if TAXPROC is TAXPROC can open the cursor . The package body of TAXPACK also includes a function called TAXFUNC.17. END mypack. each having a specification and a body. END. Refer to Section 9. Your schema contains four packages. You have also been granted privileges to access three packages (and their bodies) in other users' schemas. Which one of the following statements is NOT true? Mark for Review (1) Points The procedure can be invoked by: BEGIN taxpack.taxproc. 18. Examine the following package specification: CREATE OR REPLACE PACKAGE taxpack IS CURSOR empcurs IS SELECT * FROM employees. Mark for Review (1) Points 14 7 3 6 (*) 0 Incorrect. What will be displayed by the following query? SELECT COUNT(*) FROM ALL_OBJECTS WHERE object_type LIKE 'PACK%' AND owner <> USER. The packaage will not compile because you cannot declare a cursor in the specification.

but does not close the cursor. User SIOBHAN opens the cursor and fetches the first three rows from the cursor's active set. Which of the following will display the detailed code of the subprograms in package DEPTPACK in your schema ? Mark for Review (1) Points SELECT text FROM USER_SOURCE WHERE name = 'DEPTPACK' AND type = 'PACKAGE' ORDER BY line. True or False? Mark for Review (1) Points True False (*) Incorrect.21. FRED can immediately fetch the next three rows without opening the cursor. True or False? Mark for Review (1) Points True False (*) .Incorrect. Refer to Section 9. SELECT text FROM USER_SOURCE WHERE name = 'DEPTPACK' AND type = 'BODY' ORDER BY line. User FRED now connects to the database. When a user session changes the value of a package variable. 19. (*) SELECT text FROM USER_SOURCE WHERE object_name = 'DEPTPACK' AND object_type = 'PACKAGE BODY' ORDER BY line. Refer to Section 9. Incorrect. Refer to Section 9. A cursor is declared in a package specification. 20. the new value can immediately be seen by other sessions. SELECT text FROM USER_SOURCE WHERE name = 'DEPTPACK' AND type = 'PACKAGE BODY' ORDER BY line.

) for Review (1) Points (Choose all correct answers) AFTER LOGOFF ON SCHEMA (*) AFTER LOGON ON SCHEMA BEFORE LOGOFF ON SCHEMA BEFORE DISCONNECT ON SCHEMA (*) AFTER SERVERERROR ON SCHEMA Incorrect. Which kinds of trigger can cause a mutating table problem? (Choose two. Refer to Section 10. you must not code END. 23. END. Mark for Review (1) Points You cannot code an AFTER LOGOFF trigger When using CALL.Line A BEGIN .) Mark for Review (1) Points . Mark What is wrong with the following code? CREATE TRIGGER call_trigg AFTER LOGOFF ON SCHEMA BEGIN CALL drop_proc. Refer to Section 10. The CALL statement must not end with a semicolon (.Correct 22. 24. Examine this code: CREATE TRIGGER de_trigg -... Which of the following are NOT valid at Line A ? (Choose two.) All of the above (*) Incorrect. you must not code BEGIN When using CALL.

Refer to Section 10.(Choose all correct answers) BEFORE UPDATE row triggers (*) DDL triggers AFTER DELETE row triggers (*) Database Event triggers INSTEAD OF triggers Incorrect. What is the purpose of using the CALL statement in a Mark for Review trigger? (1) Points statement trigger. It allows both DML events and DDL events to be handled using a single trigger. in a separate procedure.. 25.Line A BEGIN INSERT INTO errlog_table VALUES (.. The database administrator wants to write a log record every time an Oracle Server error occurs in any user's session. (*) It allows an INSTEAD OF trigger to be a It allows the trigger body code to be placed It prevents cascading triggers. END. The DBA creates the following trigger: CREATE TRIGGER log_errs_trigg -.26. It allows the trigger body code to be placed in a separate procedure or function. Incorrect. What should the DBA code at Line A ? Mark for Review (1) Points AFTER ERROR ON DATABASE AFTER SERVER ERROR ON DATABASE AFTER SERVERERROR ON SCHEMA AFTER SERVERERROR ON DATABASE (*) AFTER ORACLE ERROR ON SCHEMA .). Refer to Section 10.

Refer to Section 10. 28. Which of the following can be used in place of reserved_word? (Choose two. 27. Which of the following statements could cause a DDL trigger to fire? Mark for Review (1) Points DROP TABLE employees. Examine this code: CREATE TRIGGER new_trigg AFTER CREATE ON reserved_word BEGIN .. CREATE TABLE newemp AS SELECT * FROM employees. Refer to Section 10. Refer to Section 10.. 29.) Mark for Review (1) Points (Choose all correct answers) TABLE SCHEMA (*) USER DATABASE (*) TABLE employees Incorrect. trigger body? (1) Points Which dictionary view shows the detailed code of a Mark for Review USER_SOURCE USER_TRIGGERS (*) . All of the above (*) Incorrect.Incorrect.2)). TRUNCATE TABLE locations. ALTER TABLE departments ADD (budget NUMBER(8.

dropped. END.EMPLOYEES (*) JOE does not need any object privileges.employee_id. JOE creates the following trigger: CREATE TRIGGER upd_trigg AFTER DELETE ON joe. but TOM needs DELETE on MARY. The trigger is dropped but the table is not .EMPLOYEES TOM needs DELETE on JOE.EMPLOYEES TOM needs DELETE on MARY. What object privileges will TOM and JOE need? Mark for Review (1) Points TOM does not need any object privileges.31. MARY and JOE's schemas each contain an EMPLOYEES table..locations BEGIN .EMPLOYEES and JOE needs EXECUTE on TOM. The table is dropped and the trigger is disabled.EMPLOYEES and MARY.USER_OBJECTS USER_DML_TRIGGERS USER_SUBPROGRAMS Incorrect.EMPLOYEES and JOE needs DELETE on MARY.UPD_TRIGG Incorrect. but JOE needs DELETE on both TOM.employees FOR EACH ROW BEGIN DELETE FROM mary. 30. AYSEGUL now tries to drop the LOCATIONS table. Refer to Section User AYSEGUL successfully creates the following trigger: 10. CREATE TRIGGER loc_trigg BEFORE UPDATE ON aysegul. Refer to Section 10. A third user TOM needs to delete rows from JOE's EMPLOYEES table. What happens? Review (1) Points Mark for An error message is displayed because you cannot drop a table that is associated with a trigger.employees WHERE employee_id = :OLD..

We never need to use a forward declaration when invoking a public subprogram. A public function in a package is invoked from within a SQL statement. Incorrect. True or False? Mark for Review (1) Points True (*) False Incorrect. Incorrect. specification. True or False? Mark for Review (1) Points True False (*) Correct 33. (*) None of the above. (*) It is a procedure in a package that must be invoked before the rest of the package can be used. Refer to Section 9. The function's code can include a COMMIT statement. Refer to Section 10. 32.Both the table and the trigger are dropped. 34. . It is an anonymous block at the end of a package body. Refer to Section 9. It is an anonymous block in the package It is executed automatically every time any global variable in the package is referenced. Which of the following statements about a package initialization block is true? Mark for Review (1) Points It cannot contain any SQL statements.

p2 VARCHAR2). True or False? Mark for Review (1) Points True (*) . VARCHAR2. True or False? Mark for Review (1) Points True False (*) Correct 37. Which two of these declarations cannot be in the same package specification? PROCEDURE myproc PROCEDURE myproc PROCEDURE myproc PROCEDURE myproc (1) Points (p1 (p1 (p1 (p1 NUMBER. Mark for Review 1 and 2 1 and 3 (*) 2 and 3 3 and 4 1 and 4 Correct36.35. A trigger can be a public subprogram within a PL/SQL package. p2 NUMBER). NUMBER). p2 CHAR). You can use a trigger to prevent rows from being deleted from the EMPLOYEES table on Mondays. What type of database object would you create to write an auditing record automatically every time a user connects to the database? Mark for Review (1) Points A procedure A complex view A trigger (*) A function A package Correct 38. NUMBER.

Which of the following are good guidelines to follow when creating a database trigger? (Choose two.999. The best way to enforce this rule is by using: Mark for Review (1) Points A datatype of NUMBER(7. 40.) Mark for Review (1) Points (Choose all correct answers) Where possible. True or False? Mark for Review (1) Points True (*) False Incorrect. Refer to Section 10. A trigger can be created in the database or within an application. True or False? Mark for Review (1) Points True False (*) Incorrect.99 or less than 0. .2) for the SALARY column A database trigger A check constraint (*) An application trigger A view Correct 42.41. Refer to Section 10. A business rule states that an employee's salary cannot be greater than 99. use a trigger to enforce a foreign key constraint.False Correct 39. You can code COMMIT and ROLLBACK statements in a trigger body.

(*) It is used to find out how much free space is left on an operating system disk. Do not create a trigger that automatically fires another trigger. Do not use a trigger to replace or duplicate something which the Oracle Server does automatically. Which of the following best describes the purpose of the UTL_FILE package? Mark for Review (1) Points It is used to load binary files such as employees' photos into the database.PUT_LINE can be invoked from inside a private packaged function. True or False? Mark for Review (1) Points True (*) False . The DBMS_OUTPUT. Refer to Section 9. 44. True or False? Mark for Review (1) Points True (*) False Correct 45. Incorrect. It is used to query CHAR and VARCHAR2 columns in tables. 43. (*) Incorrect. DBMS_OUTPUT.PUT procedure places text in a buffer but does not display the contents of the buffer. (*) Use triggers to prevent unauthorized users from SELECTing confidential data. It is used to read and write text files stored outside the database.Use triggers to override privilege checking and view other users' private tables. Refer to Section 10.

'EMP_REPORT.TXT ? Mark for Review (1) Points UTL_FILE. Examine the following code. Refer to Section 10.TXT'.'EMP_REPORT.'w'). Refer to Section 9. Mark for Review (1) Points .'Updating last name not allowed'). END.'c').CREATE('FILESDIR'. END IF.TXT'.. An Oracle directory called FILESDIR has been created by executing: CREATE OR REPLACE DIRECTORY filesdir AS 'C:\NEWFILES'.OPEN('FILESDIR'.'w'). It should raise an application error if a user tries to update an employee's last name. (*) UTL_FILE.FOPEN('FILESDIR'..FOPEN('C:\NEWFILES\EMP_REPORT. UTL_FILE.'EMP_REPORT. UTL_FILE. 47. What should be coded at line A? CREATE TRIGGER stop_ln_trigg BEFORE UPDATE ON employees BEGIN -. Which of the following will create a new text file called C:\NEWFILES\EMP_REPORT.TXT'. It should allow updates to all other columns of the EMPLOYEES table.TXT'). Incorrect. To create a row trigger.Correct46. Examine the following trigger. 48. what code should be included at Line A? CREATE TRIGGER dept_trigg AFTER UPDATE OR DELETE ON departments -.Line A BEGIN .Line A RAISE_APPLICATION_ERROR(-20201. Mark for Review (1) Points AFTER EACH ROW FOR EVERY ROW FOR EACH ROW (*) ON EACH ROW ON EVERY ROW Incorrect.

There are 3 employees in department 90 and 5 employees in department 50. Refer to Section 10. Refer to Section 10. With which kind of trigger can the :OLD and :NEW qualifiers be used? Mark for Review (1) Points DDL triggers Database Event triggers Statement triggers Row triggers (*) AFTER triggers .IF UPDATING LAST_NAME THEN IF UPDATING('LAST_NAME') THEN (*) IF UPDATE('LAST_NAME') THEN IF UPDATING THEN Incorrect. How many times will the trigger fire? (1) Points Once Three times (*) Mark for Review Four times Five times Eight times Incorrect. The following trigger has been created: CREATE TRIGGER upd_emp_trigg AFTER UPDATE ON employees FOR EACH ROW BEGIN A user now executes: UPDATE employees SET department_id = 50 WHERE department_id = 90. 50. 49.

Refer to Section 10. .Incorrect.

and question scores below.1.EXECUTE(v_grant_stmt). feedback. Mary has successfully granted the privilege to Henry. v_second_string VARCHAR2(6) := ' DATE)'.. MARY wants HENRY to be able to query her EMPLOYEES table.. Incorrect. A public packaged procedure contains the following SQL statement: Mark for Review When the package specification is created When the package body is created (*) When the package header is loaded into memory. END. Line A END. DBMS_SQL. True or False? Mark for Review (1) Points True False (*) Correct UPDATE employees SET salary = salary * 1. An asterisk (*) indicates a correct answer. CREATE OR REPLACE PROCEDURE addcol (p_col_name IN VARCHAR2) IS v_first_string VARCHAR2(100) := 'ALTER TABLE EMPLOYEES ADD ('. BEGIN . The name of the new column is passed to the procedure as a parameter. Refer to Section 9. 3.Test: Mid Term Exam Semester 2 Review your answers. . Mary executes the following code: DECLARE v_grant_stmt VARCHAR2(50). BEGIN v_grant_stmt := 'GRANT SELECT ON employees TO henry'. When is this SQL statement parsed? (1) Points 2. Only the first time the procedure is executed. When the package is loaded into memory. Mid Term Exam Semester 2 1. The following procedure adds a column of datatype DATE to the EMPLOYEES table.

BEGIN FOR v_curs_rec IN c_curs LOOP EXECUTE IMMEDIATE 'DROP VIEW ' || v_curs_rec.Which of the following will work correctly when coded at line A? (Choose two. END LOOP. Correct 5. Correct 4. The procedure will raise an exception because one of the views is a complex view. Examine the following code: CREATE OR REPLACE PROCEDURE myproc IS CURSOR c_curs IS SELECT view_name FROM user_views. True or False? Mark for Review (1) Points .view_name. What will happen when this procedure is invoked? Mark for Review (1) Points All views in the user's schema will be dropped. END. EXECUTE (*) EXECUTE IMMEDIATE 'v_first_string' || p_col_name || 'v_second_string'. The procedure will raise an exception because Dynamic SQL can drop tables but cannot drop views. INSTEAD OF triggers are always row triggers. even if FOR EACH ROW is omitted. v_first_string := v_first_string || p_col_name. IMMEDIATE v_first_string || p_col_name || v_second_string. EXECUTE (*) IMMEDIATE v_first_string || v_second_string. EXECUTE v_first_string || p_col_name || v_second_string.) Mark for Review (1) Points (Choose all correct answers) v_first_string || p_col_name || v_second_string. (*) The procedure will not compile successfully because the syntax of EXECUTE IMMEDIATE is incorrect.

True (*) False Correct Page 1 of 10 Test: Mid Term Exam Semester 2 Review your answers. Mid Term Exam Semester 2 6. 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 . Mark for Review (1) Points AFTER EACH ROW FOR EVERY ROW FOR EACH ROW (*) ON EACH ROW ON EVERY ROW Correct 7.) Mark for Review (1) Points (Choose all correct answers) IF DELETING THEN IF SELECTING THEN (*) IF INSERTING THEN IF UPDATING ('JOB_ID') THEN IF OTHERS THEN (*) ... feedback. Which of the following can NOT be coded in the body of a DML trigger? (Choose two. An asterisk (*) indicates a correct answer. and question scores below.

Examine the following code: CREATE TRIGGER emp_trigg AFTER UPDATE OF salary ON employees FOR EACH ROW DECLARE v_count NUMBER. END.Line A BEGIN INSERT INTO errlog_table VALUES (.. The DBA creates the following trigger: CREATE TRIGGER log_errs_trigg -.. With which kind of trigger can the :OLD and :NEW qualifiers be used? Mark for Review (1) Points DDL triggers Database Event triggers Statement triggers Row triggers (*) AFTER triggers Correct 9.Correct 8. The database administrator wants to write a log record every time an Oracle Server error occurs in any user's session. What should the DBA code at Line A ? Mark for Review (1) Points AFTER ERROR ON DATABASE AFTER SERVER ERROR ON DATABASE AFTER SERVERERROR ON SCHEMA AFTER SERVERERROR ON DATABASE (*) AFTER ORACLE ERROR ON SCHEMA Correct 10. Which of the following statements is NOT allowed at Line A? Mark for Review (1) Points .). BEGIN -.Line A END.

feedback. Page 2 of 10 Test: Mid Term Exam Semester 2 Review your answers. Refer to Section 10. SELECT count(*) INTO v_count FROM employees. and question scores below. (*) Mark . A trigger automatically inserts a row into a logging table every What kind of trigger is this? (1) Points A row trigger A statement trigger Mark for Review A database event trigger (*) A DDL trigger An AFTER trigger Correct 12. Mid Term Exam Semester 2 time a user's session receives this error message: ORA-00942: table or view does not exist 11. None. Incorrect. What is the purpose of using the CALL statement in a trigger? for Review (1) Points It allows an INSTEAD OF trigger to be a statement trigger. All of the above are allowed.SELECT count(*) INTO v_count FROM departments.employee_id. UPDATE employees SET job_id = 'IT_PROG' WHERE employee_id = :OLD.PUT_LINE('A salary was updated'). It allows the trigger body code to be placed in a separate procedure. (*) DBMS_OUTPUT. An asterisk (*) indicates a correct answer.

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 -. It allows the trigger body code to be placed in a separate procedure or function. DROP ON SCHEMA AFTER ALTER. END. Which of the following statements could cause a DDL trigger to fire? Mark for Review (1) Points DROP TABLE employees.Line A BEGIN RAISE_APPLICATION_ERROR(-20203. It allows both DML events and DDL events to be handled using a single trigger.'Invalid Operation'). . Correct 13. DROP ON SCHEMA Correct 14.2)).It prevents cascading triggers. What should you code at Line A ? Mark for Review (1) Points AFTER ALTER OR DROP ON SCHEMA INSTEAD OF ALTER OR DROP ON SCHEMA BEFORE ALTER OR DROP ON SCHEMA (*) BEFORE ALTER. What is wrong with the following code? CREATE TRIGGER call_trigg AFTER LOGOFF ON SCHEMA BEGIN CALL drop_proc. All of the above (*) Correct 15. CREATE TABLE newemp AS SELECT * FROM employees. TRUNCATE TABLE locations. ALTER TABLE departments ADD (budget NUMBER(8.

you must not code BEGIN When using CALL. Mark for Review (1) Points You cannot code an AFTER LOGOFF trigger When using CALL. public components are declared in the specification but private components are not. DROP PACKAGE bigpack SPECIFICATION. . The CALL statement must not end with a semicolon (. Mid Term Exam Semester 2 16. We want to remove the specification (but not the body) of package BIGPACK from the database.) All of the above (*) Correct Page 3 of 10 Test: Mid Term Exam Semester 2 Review your answers.END. DROP PACKAGE HEADER bigpack. True or False? Mark for Review (1) Points True (*) False Correct 17. and question scores below. DROP PACKAGE SPECIFICATION bigpack. feedback. In a package. Which of the following commands will do this? Mark for Review (1) Points DROP PACKAGE bigpack. An asterisk (*) indicates a correct answer. you must not code END.

(*) SELECT text FROM USER_SOURCE WHERE object_name = 'DEPTPACK' AND object_type = 'PACKAGE BODY' ORDER BY line. the (*) The packaage will not compile because you cannot declare a cursor in specification. 19. END.None of the above (*) Correct 18. CREATE OR REPLACE PACKAGE taxpack IS PROCEDURE END mypack. CURSOR empcurs IS SELECT * FROM employees. TAXPROC is a public procedure and TAXFUNC is a private function TAXPROC can invoke TAXFUNC if TAXPROC is coded before TAXFUNC TAXPROC can open the cursor Incorrect. Which one of the following statements is NOT true? Mark for Review (1) Points The procedure can be invoked by: BEGIN taxpack. Which of the following will display the detailed code of the subprograms in package DEPTPACK in your schema ? Mark for Review (1) Points SELECT text FROM USER_SOURCE WHERE name = 'DEPTPACK' AND type = 'PACKAGE' ORDER BY line. SELECT text FROM USER_SOURCE WHERE name = 'DEPTPACK' AND type = 'PACKAGE BODY' ORDER BY line. Refer to Section 9. Examine the following package specification: taxproc. The package body of TAXPACK also includes a function called TAXFUNC. .taxproc.

Correct 20. Mid Term Exam Semester 2 21. An asterisk (*) indicates a correct answer. Both the specification and the body will be dropped. Mark for Review (1) Points The body will be dropped but the specification will be retained. What will happen when the following statement is executed? DROP PACKAGE oldpack. (*) . The whole package is loaded into memory when the first call is made to any subprogram in the package. The public subprograms are all loaded into memory at the same time. feedback. there will be three copies of the code in memory. and question scores below. Correct Page 4 of 10 Test: Mid Term Exam Semester 2 Review your answers. Package OLDPACK is in your schema. (*) If three users invoke three different subprograms in the package.SELECT text FROM USER_SOURCE WHERE name = 'DEPTPACK' AND type = 'BODY' ORDER BY line. Which one of the following statements is true? (1) Points Mark for Review Each subprogram is loaded into memory when it is first invoked. but the private subprograms are loaded into memory one at a time as they are invoked. A package contains both public and private subprograms. The specification will be dropped but the body will be retained.

The statement will fail because you must drop the body before you can drop the specification. Correct 22. 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; Mark for Review (1) Points 14 7 3 6 (*) 0 Incorrect. Refer to Section 9. 23. 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 Mark for Review (1) Points The first 15 rows will be fetched. The first 10 rows will be fetched, then the first 5 rows will be fetched again.

The first 5 rows will be fetched three times.
An error will occur at line 2. An error will occur at line 4. (*)

Correct

24. When a user session changes the value of a package variable, the new value can immediately be seen by other sessions. True or False? Mark for Review (1) Points True False (*)

Incorrect. Refer to Section 9. 25. A trigger can be created in the database or within an application. True or False? Mark for Review (1) Points True (*) False Incorrect. Refer to Section 10.

Page 5 of 10

Test: Mid Term Exam Semester 2

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer. Mid Term Exam Semester 2 26. You can use a trigger to prevent rows from being deleted from the EMPLOYEES table on Mondays. True or False? Mark for Review (1) Points True (*) False Incorrect. Refer to Section 10. 27. What type of database object would you create to write an auditing record automatically every time a user connects to the database? Mark for Review (1) Points

A procedure A complex view A trigger (*) A function A package Correct 28. A trigger can be a public subprogram within a PL/SQL package. True or False? Mark for Review (1) Points True False (*) Correct 29. Which of the following are NOT stored inside the database? (Choose two.) Mark for Review (1) Points (Choose all correct answers) A PL/SQL package specification A database trigger An anonymous block (*) An application trigger (*) A sequence Incorrect. Refer to Section 10. 30. Which of the following best describes a database trigger? Review (1) Points Mark for

A subprogram that checks whether a user has typed the correct password to log on to the database. A PL/SQL subprogram that executes automatically whenever an associated database event occurs. (*) A PL/SQL subprogram that always returns exactly one value. A subprogram that is invoked explicitly by the calling application. A PL/SQL subprogram that inserts rows into a logging table.

'Invalid salary'). CREATE OR REPLACE PACKAGE BODY emppack IS -. Mid Term Exam Semester 2 31. p_salary IN NUMBER). An asterisk (*) indicates a correct answer.2) for the SALARY column A database trigger A check constraint (*) An application trigger A view Incorrect. and question scores below. END emppack.99 or less than 0. . Examine the following code: CREATE OR REPLACE PACKAGE emppack IS PROCEDURE upd_emp (p_empno IN NUMBER.999. Refer to Section 10.Correct Page 6 of 10 Test: Mid Term Exam Semester 2 Review your answers. A business rule states that an employee's salary cannot be greater than 99. feedback. END IF. 32. END IF. END upd_emp.Line A PROCEDURE upd_emp (p_empno IN NUMBER. The best way to enforce this rule is by using: Mark for Review (1) Points A datatype of NUMBER(7. p_salary IN NUMBER) IS BEGIN IF NOT sal_ok(p_salary) THEN RAISE_APPLICATION_ERROR(-20201. FUNCTION sal_ok(pf_salary NUMBER) RETURN BOOLEAN IS BEGIN IF pf_salary > 50000 THEN RETURN FALSE. END sal_ok. END emppack. ELSE RETURN TRUE.

What must be coded at Line A for this package to compile successfully? Mark for Review (1) Points FUNCTION sal_ok. True or False? Mark for Review (1) Points True False (*) Incorrect. Package HRPACK contains the following public function: FUNCTION empfunc (p_deptno NUMBER) RETURN NUMBER IS BEGIN UPDATE employees SET salary = salary * 1. Mark for Review (1) Points hrpack. (*) Incorrect.1 WHERE department_id = p_deptno. The SELECT will fail because you cannot execute a DML statement from within a query. END empfunc. The SELECT will succeed because it is referencing a different table from the function. The function's code can include a COMMIT statement.empfunc(department_id) The SELECT will fail because you cannot return SQL%ROWCOUNT from a packaged function. p_salary IN NUMBER). Refer to Section 9. FUNCTION sal_ok(pf_salary NUMBER). 34. What will happen when the following SQL statement is executed? SELECT department_name. Refer to Section 9. FUNCTION sal_ok(pf_salary NUMBER) RETURN BOOLEAN. The SELECT will fail because you cannot call packaged functions from within a SQL statement. A public function in a package is invoked from within a SQL statement. FROM departments. . Nothing is needed at Line A Correct 33. RETURN SQL%ROWCOUNT. (*) PROCEDURE upd_emp (p_empno IN NUMBER.

(*) None of the above. True or False? Mark for Review (1) Points True (*) False Correct Page 7 of 10 Test: Mid Term Exam Semester 2 Review your answers. Both the table and the trigger are dropped. AYSEGUL now tries to drop the LOCATIONS table.locations BEGIN . JOE creates the following trigger: CREATE TRIGGER upd_trigg AFTER DELETE ON joe. User AYSEGUL successfully creates the following trigger: CREATE TRIGGER loc_trigg BEFORE UPDATE ON aysegul.employees . Mid Term Exam Semester 2 36. What happens? Mark for Review (1) Points An error message is displayed because you cannot drop a table that is associated with a trigger.. and question scores below. An asterisk (*) indicates a correct answer. MARY and JOE's schemas each contain an EMPLOYEES table. Correct 37.35. The table is dropped and the trigger is disabled. We never need to use a forward declaration when invoking a public subprogram. feedback. The trigger is dropped but the table is not dropped.employees FOR EACH ROW BEGIN DELETE FROM mary..

DROP TRIGGER emp_trigg. SYSDATE). A user now executes: UPDATE employees SET salary = salary * 1.EMPLOYEES and JOE needs EXECUTE on TOM.employee_id. (*) REMOVE TRIGGER emp_trigg.EMPLOYEES (*) JOE does not need any object privileges. END. How many rows will be inserted into audit_table? Mark for Review (1) Points One (*) .EMPLOYEES and MARY.UPD_TRIGG Correct 38.EMPLOYEES TOM needs DELETE on MARY. but JOE needs DELETE on both TOM.1 WHERE department_id = 50. Which of the following will remove a trigger in your schema named EMP_TRIGG from the database? Mark for Review (1) Points DROP emp_trigg TRIGGER. but TOM needs DELETE on MARY. What object privileges will TOM and JOE need? Mark for Review (1) Points TOM does not need any object privileges. ALTER TRIGGER emp_trigg DISABLE. A third user TOM needs to delete rows from JOE's EMPLOYEES table. None of the above Correct 39.EMPLOYEES and JOE needs DELETE on MARY.EMPLOYEES TOM needs DELETE on JOE.WHERE employee_id = :OLD. 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. END.

department_name The second line should be: . BEFORE UPDATE ON departments. What is wrong with the following code? CREATE TRIGGER dept_trigg BEFORE UPDATE OF department_name ON departments BEGIN END. while a row trigger fires once for each row processed by the triggering statement. and question scores below. You cannot use :NEW or :OLD in a statement trigger. Mid Term Exam Semester 2 41. feedback. An asterisk (*) indicates a correct answer.PUT_LINE(:NEW. Mark for Review (1) Points You cannot use :NEW in a BEFORE trigger. True or False? Mark for Review (1) Points True (*) False Correct Page 8 of 10 Test: Mid Term Exam Semester 2 Review your answers.PUT_LINE inside a trigger.Two Five Six None of the above Correct 40. (*) You cannot use DBMS_OUTPUT. A DML statement trigger fires only once for each triggering DML statement. only in an AFTER trigger. DBMS_OUTPUT.department_name).

What is wrong with the following syntax for creating a package specification? CREATE OR REPLACE PACKAGE mypack IS g_constant1 NUMBER(6) := 100. Correct . Mark for Review (1) Points You cannot declare constants in the specification.Correct 42. FUNCTION func2. The RETURN datatype of the functions must be specified. END.Line A BEGIN INSERT INTO log_table VALUES (USER. Which of the following can NOT be coded at Line A? Mark for Review (1) Points BEFORE UPDATE ON employees AFTER INSERT OR DELETE ON employees AFTER SELECT ON employees (*) BEFORE DELETE ON employees AFTER UPDATE OF last_name ON employees Correct 43. FUNCTION func1 (p_param1 IN VARCHAR2). this code contains no errors. (*) The first line should be: CREATE OR REPLACE PACKAGE SPECIFICATION mypack IS Nothing is wrong. Examine the following code: CREATE TRIGGER emp_trigg -. SYSDATE). END mypack. A package must contain at least one procedure.

You can see which parameters MYPROC uses by executing: DESCRIBE mypack.44. Which one of the following can NOT be part of a Package ? Review (1) Points Procedures Explicit cursors Mark for Triggers (*) Functions Global variables Correct Page 9 of 10 Test: Mid Term Exam Semester 2 Review your answers. and question scores below. Triue or False? Mark for Review (1) Points True (*) False Correct 45. feedback. Mid Term Exam Semester 2 46. Every subprogram which has been declared in a package specification must also be included in the package body. True or False? Mark for Review (1) Points True False (*) Correct . Package MYPACK contains procedure MYPROC. An asterisk (*) indicates a correct answer.myproc.

(*) .FOPEN('FILESDIR'. Correct 50. (*) It is used to find out how much free space is left on an operating system disk. Refer to Section 9.CREATE('FILESDIR'.'w'). True or False? (1) Points True (*) False Correct Mark for Review 48.'EMP_REPORT. Why is it better to use DBMS_OUTPUT only in anonymous blocks. DBMS_OUTPUT. Which of the following will create a new text file called C:\NEWFILES\EMP_REPORT. UTL_FILE. It is used to read and write text files stored outside the database. Which of the following best describes the purpose of the UTL_FILE package? Mark for Review (1) Points It is used to load binary files such as employees' photos into the database.PUT_LINE can be invoked from inside a private packaged function. It is used to query CHAR and VARCHAR2 columns in tables.'EMP_REPORT. not inside stored subprograms such as procedures? Mark for Review (1) Points Because DBMS_OUTPUT cannot be used inside procedures while procedures do not display anything until their execution has finished Because DBMS_OUTPUT should be used only for testing and debugging PL/SQL code (*) Because DBMS_OUTPUT can raise a NO_DATA_FOUND exception if used inside a packaged procedure Incorrect. UTL_FILE. An Oracle directory called FILESDIR has been created by executing: CREATE OR REPLACE DIRECTORY filesdir AS 'C:\NEWFILES'.TXT').FOPEN('C:\NEWFILES\EMP_REPORT.'w').TXT'. 49.TXT ? Mark for Review (1) Points UTL_FILE.TXT'.47. Because anonymous blocks display messages while the block is executing.

Incorrect. Examine the following code: CREATE TRIGGER emp_trigg -. (*) CREATE TRIGGER emp_upd_trigg AFTER UPDATE OF (salary. CREATE TRIGGER emp_upd_trigg AFTER UPDATE OF salary OR job_id ON employees BEGIN . You need to create a trigger that will fire whenever an employee's salary or job_id is updated. feedback.. job_id) ON employees BEGIN ...UTL_FILE. Mid Term Exam Semester 2 1. and question scores below... CREATE TRIGGER emp_upd_trigg job_id) AFTER UPDATE OF salary.. 2.'EMP_REPORT.. An asterisk (*) indicates a correct answer. BEGIN .TXT'. but not when any other column of the EMPLOYEES table is updated. Refer to Section 10.'c'). Which of the following is the correct syntax to do this? Mark for Review (1) Points CREATE TRIGGER emp_upd_trigg AFTER UPDATE ON employees (salary.. job_id ON employees BEGIN .OPEN('FILESDIR'. Correct Page 10 of 10 Test: Mid Term Exam Semester 2 Review your answers.Line A .

BEGIN INSERT INTO log_table VALUES (USER, SYSDATE); END;

Which of the following can NOT be coded at Line A?
Mark for Review (1) Points BEFORE UPDATE ON employees AFTER INSERT OR DELETE ON employees AFTER SELECT ON employees (*) BEFORE DELETE ON employees AFTER UPDATE OF last_name ON employees Correct

3. 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; Mark for Review (1) Points True False (*) Incorrect. Refer to Section 10.

4.
BEGIN END;

What is wrong with the following code?

CREATE TRIGGER dept_trigg

BEFORE UPDATE OF department_name ON departments DBMS_OUTPUT.PUT_LINE(:NEW.department_name);

Mark for Review (1) Points You cannot use :NEW in a BEFORE trigger, only in an AFTER trigger. You cannot use :NEW or :OLD in a statement trigger. (*) You cannot use DBMS_OUTPUT.PUT_LINE inside a trigger.

BEFORE UPDATE ON departments.department_name

The second line should be:

Correct

5. Which one of the following can NOT be part of a Package ? Review (1) Points Procedures Explicit cursors

Mark for

Triggers (*) Functions Global variables

Correct

Page 1 of 10

Test: Mid Term Exam Semester 2

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer. Mid Term Exam Semester 2

parameters MYPROC uses by executing: DESCRIBE mypack.myproc. True or False?
Mark for Review (1) Points True False (*) Correct 7. Which part of a package must be created first, the specification or the body? Mark for Review (1) Points The body The specification (*) The specification and body must be created at the same time.

6.

Package MYPACK contains procedure MYPROC. You can see which

It does not matter which is created first.

The body can be created first, but only if the package has no specification. Correct 8. The following package specification has been created: CREATE OR REPLACE PACKAGE mypack IS

FUNCTION myfunc(p_funcparam DATE) RETURN BOOLEAN;

PROCEDURE myproc(p_procparam IN NUMBER); END mypack; Which of the following will correctly invoke the package subprograms? (Choose two.) Mark for Review (1) Points (Choose all correct answers) mypack.myfunc('22-JAN-07'); mypack.myproc(35); (*) IF NOT mypack.myfunc(SYSDATE) THEN DBMS_OUTPUT.PUT_LINE('Message'); END IF; (*) myproc(40); v_num := mypack.myproc(22);

Incorrect. Refer to Section 9. 9. The database administrator wants to write a log record every time an Oracle Server error occurs in any user's session. The DBA creates the following trigger: CREATE TRIGGER log_errs_trigg -- Line A BEGIN INSERT INTO errlog_table VALUES (...); END; What should the DBA code at Line A ? Mark for Review (1) Points AFTER ERROR ON DATABASE AFTER SERVER ERROR ON DATABASE AFTER SERVERERROR ON SCHEMA

) Mark for Review . BEGIN -.. Examine this code: CREATE TRIGGER de_trigg -. Which of the following statements is NOT allowed at Line A? Mark for Review (1) Points SELECT count(*) INTO v_count FROM departments. and question scores below. Correct Page 2 of 10 Test: Mid Term Exam Semester 2 Review your answers.Line A END.employee_id. Examine the following code: CREATE TRIGGER emp_trigg AFTER UPDATE OF salary ON employees FOR EACH ROW DECLARE v_count NUMBER. SELECT count(*) INTO v_count FROM employees. Mid Term Exam Semester 2 11. None.AFTER SERVERERROR ON DATABASE (*) AFTER ORACLE ERROR ON SCHEMA Correct 10. UPDATE employees SET job_id = 'IT_PROG' WHERE employee_id = :OLD.Line A BEGIN . feedback.PUT_LINE('A salary was updated'). An asterisk (*) indicates a correct answer.. (*) DBMS_OUTPUT. All of the above are allowed. Which of the following are NOT valid at Line A ? (Choose two.

A trigger automatically inserts a row into a logging table every What kind of trigger is this? (1) Points A row trigger A statement trigger A database event trigger (*) A DDL trigger An AFTER trigger Correct Mark for Review 14. Correct Mark for time a user's session receives this error message: ORA-00942: table or view does not exist 13. 12. Refer to Section 10. You want to prevent any objects in your schema from being altered or dropped. It allows the trigger body code to be placed in a separate procedure.(1) Points (Choose all correct answers) AFTER LOGOFF ON SCHEMA (*) AFTER LOGON ON SCHEMA BEFORE LOGOFF ON SCHEMA BEFORE DISCONNECT ON SCHEMA (*) AFTER SERVERERROR ON SCHEMA Incorrect. 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. (*) It prevents cascading triggers. What is the purpose of using the CALL statement in a trigger? Review (1) Points It allows an INSTEAD OF trigger to be a statement trigger. You decide to create the following trigger: .

) Mark for Review (1) Points (Choose all correct answers) BEFORE UPDATE row triggers (*) DDL triggers AFTER DELETE row triggers (*) Database Event triggers INSTEAD OF triggers Correct Page 3 of 10 Test: Mid Term Exam Semester 2 Review your answers. feedback. An asterisk (*) indicates a correct answer.CREATE TRIGGER stop_ad_trigg -. What should you code at Line A ? Mark for Review (1) Points AFTER ALTER OR DROP ON SCHEMA INSTEAD OF ALTER OR DROP ON SCHEMA BEFORE ALTER OR DROP ON SCHEMA (*) BEFORE ALTER. DROP ON SCHEMA AFTER ALTER.Line A BEGIN RAISE_APPLICATION_ERROR(-20203. Which kinds of trigger can cause a mutating table problem? (Choose two. and question scores below. DROP ON SCHEMA Operation'). Mid Term Exam Semester 2 . Correct 15.'Invalid END.

A SQL statement can pass through several stages. Which of the following is NOT one of these stages? Mark for Review (1) Points BIND FETCH PARSE RETURN (*) EXECUTE Correct 18. BEGIN FOR v_curs_rec IN c_curs LOOP EXECUTE IMMEDIATE 'DROP VIEW ' || v_curs_rec... Examine the following code: CREATE OR REPLACE PROCEDURE myproc IS CURSOR c_curs IS SELECT view_name FROM user_views.. 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 (Choose all correct answers) DELETE SAVEPOINT ALTER (*) SELECT . END LOOP. The procedure will raise an exception because one of the views is a complex view. END.16.view_name. The procedure will raise an exception because Dynamic SQL can drop tables but cannot drop views. 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 not compile successfully because the syntax of EXECUTE IMMEDIATE is incorrect. FOR UPDATE NOWAIT GRANT (*) .. Correct 17.

-. CLOSEPROC closes the cursor. The package contains three public procedures: OPENPROC opens the cursor. Mary has successfully granted the privilege to Henry.fetchproc.Incorrect.line 3 curspack. (*) Correct Page 4 of 10 . -. -.closeproc. END. True or False? Mark for Review (1) Points True False (*) Correct 20.openproc.line 1 curspack. The first 5 rows will be fetched three times.fetchproc. -.fetchproc. then the first 5 rows will be fetched again. The first 10 rows will be fetched.openproc. An error will occur at line 4. An error will occur at line 2.line 2 curspack. 19. Package CURSPACK declares a global cursor in the package specification. BEGIN v_grant_stmt := 'GRANT SELECT ON employees TO henry'. FETCHPROC fetches 5 rows from the cursor's active set.EXECUTE(v_grant_stmt).line 6 Mark for Review (1) Points The first 15 rows will be fetched. MARY wants HENRY to be able to query her EMPLOYEES table.line 5 curspack. Refer to Section 9.line 4 curspack. What will happen when a user session executes the following commands in the order shown? curspack. -. -. DBMS_SQL. Mary executes the following code: DECLARE v_grant_stmt VARCHAR2(50).

END. True or False? Mark for Review (1) Points True False (*) Correct 23. Which two of these declarations cannot be in the same package specification? PROCEDURE myproc (p1 NUMBER. Mid Term Exam Semester 2 21. Hazel: 0 Both queries will fail because the syntax of DBMS_OUTPUT. What values will Dick and Hazel see? Mark for Review (1) Points Dick: 45.PUT_LINE is incorrect Incorrect. User HAZEL now connects to the database. An asterisk (*) indicates a correct answer. p2 NUMBER). . 22.g_myvar := 45. and question scores below. Hazel: null (*) Dick: 0. Refer to Section 9.g_myvar).Test: Mid Term Exam Semester 2 Review your answers. feedback. Both users immediately execute: BEGIN DBMS_OUTPUT.PUT_LINE(multipack. The function's code can include a COMMIT statement. User DICK executes the following: multipack. A public function in a package is invoked from within a SQL statement. p2 VARCHAR2). Package MULTIPACK declares the following global variable: g_myvar NUMBER. Hazel: 0 Dick: 45. Hazel: 45 Dick: 45. PROCEDURE myproc (p1 VARCHAR2.

Examine the following package code: CREATE OR REPLACE PACKAGE ol_pack IS PROCEDURE subprog (p1 IN VARCHAR2.PROCEDURE myproc (p1 NUMBER. PROCEDURE subprog (param1 IN CHAR. Package HRPACK contains the following public function: FUNCTION empfunc (p_deptno NUMBER) RETURN NUMBER IS BEGIN (*) UPDATE employees SET salary = salary * 1. What will happen when the following SQL statement is executed? SELECT department_name.empfunc(department_id) The SELECT will fail because you cannot return SQL%ROWCOUNT from a packaged function.30). . END ol_pack. Mark for Review (1) Points hrpack. Refer to Section 9. param2 IN NUMBER) RETURN DATE. v_date := ol_pack.) Mark for Review (1) Points (Choose all correct answers) ol_pack. 25. END empfunc.subprog(param1=>'Jane'. ol_pack.30).1 WHERE department_id = p_deptno. Mark for Review (1) Points 1 and 2 1 and 3 (*) 2 and 3 3 and 4 1 and 4 Correct 24. Which of the following calls will be successful? (Choose two. (*) v_number := ol_pack. RETURN SQL%ROWCOUNT. p2 CHAR).param2=>30).subprog('Jane'.subprog(p1=>'Jane'). p2 IN NUMBER). FROM departments. param2 IN NUMBER).subprog('Jane'. PROCEDURE myproc (p1 NUMBER). Incorrect. FUNCTION subprog (param1 IN VARCHAR2.

where should MYVAR be declared? CREATE OR REPLACE PACKAGE varpack IS -. Mark for Review (1) Points Point A Point B (*) Point C Point D . The SELECT will fail because you cannot execute a DML statement from within a query.Point A END varpack.The SELECT will fail because you cannot call packaged functions from within a SQL statement.Point C BEGIN END varproc. We need to declare a package variable named MYVAR. An asterisk (*) indicates a correct answer. (*) Correct Page 5 of 10 Test: Mid Term Exam Semester 2 Review your answers. PROCEDURE . Mid Term Exam Semester 2 26. which can be referenced by any subprogram in the package but can NOT be referenced from outside the package.Point D END varpack.. CREATE OR REPLACE PACKAGE BODY varpack IS -. In the following code. feedback. The SELECT will succeed because it is referencing a different table from the function.Point B PROCEDURE varproc IS -. and question scores below.. -.

they will both work Incorrect. Which one of the following statements is true? (1) Points Mark for Review Each subprogram is loaded into memory when it is first invoked. public components are declared in the specification but private components are not. Correct 29. there will be three copies of the code in memory. A package contains both public and private subprograms. Mark for Review (1) Points The body will be dropped but the specification will be retained. What will happen when the following statement is executed? DROP PACKAGE oldpack. True or False? Mark for Review (1) Points True (*) False Correct 28. Package OLDPACK is in your schema. Which of the following commands will do this? Mark for Review (1) Points . The public subprograms are all loaded into memory at the same time.Point B or Point C. Refer to Section 9. but the private subprograms are loaded into memory one at a time as they are invoked. The specification will be dropped but the body will be retained. 27. The whole package is loaded into memory when the first call is made to any subprogram in the package. (*) If three users invoke three different subprograms in the package. We want to remove the specification (but not the body) of package BIGPACK from the database. In a package. (*) The statement will fail because you must drop the body before you can drop the specification. Both the specification and the body will be dropped. Correct 30.

Page 6 of 10 Test: Mid Term Exam Semester 2 Review your answers. feedback. DROP PACKAGE bigpack SPECIFICATION. DROP PACKAGE SPECIFICATION bigpack. Refer to Section 9. Mid Term Exam Semester 2 31. including private function PRIVFUNC. What will be displayed by the following query? SELECT COUNT(*) FROM ALL_OBJECTS WHERE object_type LIKE 'PACK%' AND owner <> USER. . You have also been granted privileges to access three packages (and their bodies) in other users' schemas. DROP PACKAGE HEADER bigpack. Your schema contains four packages. An asterisk (*) indicates a correct answer. From where can PRIVFUNC be invoked? (Choose two. and question scores below. each having a specification and a body.) Mark for Review (1) Points (Choose all correct answers) From an anonymous block From any procedure in NEWPACK (*) From any private function in another package From any function in NEWPACK (*) From any public procedure in another package Correct 32. None of the above (*) Incorrect.DROP PACKAGE bigpack. Package NEWPACK contains several procedures and functions.

not inside stored subprograms such as procedures? Mark for Review (1) Points Because DBMS_OUTPUT cannot be used inside procedures Because anonymous blocks display messages while the block is executing.Mark for Review (1) Points 14 7 3 6 (*) 0 Correct 33.PUT procedure places text in a buffer but does not display the contents of the buffer. True or False? Mark for Review (1) Points True False (*) Correct . The UTL_FILE package can be used to create binary files such as JPEGs as well as text files. True or False? Mark for Review (1) Points True (*) False Correct 34. while procedures do not display anything until their execution has finished Because DBMS_OUTPUT should be used only for testing and debugging PL/SQL code (*) Because DBMS_OUTPUT can raise a NO_DATA_FOUND exception if used inside a packaged procedure Correct 35. The DBMS_OUTPUT. Why is it better to use DBMS_OUTPUT only in anonymous blocks.

You need to disable all triggers that are associated with DML statements on the DEPARTMENTS table. Refer to Section 9. Which of the following commands should you use? Mark for Review (1) Points ALTER TABLE departments DISABLE ALL TRIGGERS. (*) ALTER TRIGGER DISABLE ALL ON departments.Page 7 of 10 Test: Mid Term Exam Semester 2 Review your answers. END. . and question scores below.PUT('beside the seaside').PUT_LINE('to be').PUT('I do like'). DISABLE ALL TRIGGERS ON departments. DBMS_OUTPUT. feedback. Mark for Review (1) Points 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 (*) I do like to be beside the seaside Incorrect. ALTER TABLE departments DISABLE TRIGGERS. An asterisk (*) indicates a correct answer. Mid Term Exam Semester 2 36. DBMS_OUTPUT. 37. What will be displayed when the following code is executed? BEGIN DBMS_OUTPUT.

employees FOR EACH ROW BEGIN DELETE FROM mary.EMPLOYEES (*) JOE does not need any object privileges. Mark for Review (1) Points True (*) False Correct 39. but will remain in the database. JOE creates the following trigger: CREATE TRIGGER upd_trigg AFTER DELETE ON joe. but JOE needs DELETE on both TOM. You can use a trigger to prevent rows from being deleted from the EMPLOYEES table on Mondays.UPD_TRIGG Correct 40. A third user TOM needs to delete rows from JOE's EMPLOYEES table.EMPLOYEES and MARY.ALTER TABLE departments DROP ALL TRIGGERS. After the following SQL statement is executed. True or False? ALTER TABLE departments DISABLE ALL TRIGGERS.EMPLOYEES TOM needs DELETE on MARY.EMPLOYEES TOM needs DELETE on JOE.employee_id. but TOM needs DELETE on MARY.EMPLOYEES and JOE needs DELETE on MARY. Correct 38.employees WHERE employee_id = :OLD. END. MARY and JOE's schemas each contain an EMPLOYEES table. What object privileges will TOM and JOE need? Mark for Review (1) Points TOM does not need any object privileges.EMPLOYEES and JOE needs EXECUTE on TOM. all the triggers on the DEPARTMENTS table will no longer fire. True or False? Mark for Review (1) Points True (*) False .

A trigger can be a public subprogram within a PL/SQL package. Which of the following best describes a database trigger? Review (1) Points Mark for A subprogram that checks whether a user has typed the correct password to log on to the database. An asterisk (*) indicates a correct answer. (*) executes automatically whenever an associated A PL/SQL subprogram that always returns exactly one value. Correct 43. feedback.Correct Page 8 of 10 Test: Mid Term Exam Semester 2 Review your answers. A PL/SQL subprogram that inserts rows into a logging table. A subprogram that is invoked explicitly by the calling application. True or False? Mark for Review (1) Points True False (*) Correct 42. You can code COMMIT and ROLLBACK statements in a trigger body. Mid Term Exam Semester 2 41. and question scores below. True or False? Mark for Review (1) Points True False (*) . A PL/SQL subprogram that database event occurs.

use a trigger to enforce a foreign key constraint. Review (1) Points A procedure A complex view A trigger (*) A function A package Correct What type of database object would you create to write an auditing Mark for record automatically every time a user connects to the database? Page 9 of 10 Test: Mid Term Exam Semester 2 Review your answers. feedback.) (1) Points (Choose all correct answers) Mark for Review Where possible. Do not create a trigger that automatically fires another trigger. and question scores below. An asterisk (*) indicates a correct answer. (*) Use triggers to prevent unauthorized users from SELECTing confidential data. Do not use a trigger to replace or duplicate something which the Oracle Server does automatically. Which of the following are good guidelines to follow when creating a database trigger? (Choose two. .Correct 44. (*) Correct 45. Use triggers to override privilege checking and view other users' private tables.

True or False? Mark for Review (1) Points . A business rule states that an employee's salary cannot be greater than 99. There are 3 employees in department 90 and 5 employees in department INSTEAD OF INSERT OR UPDATE ON my_object_name FOR EACH ROW BEGIN . my_object_name can be the name of a table... In the following code: CREATE TRIGGER mytrigg 47.99 or less than 0.999. How many times will the trigger fire? Mark for Review (1) Points Once Three times (*) Four times Five times Eight times Correct 48.2) for the SALARY column A database trigger A check constraint (*) An application trigger A view Correct 50.Mid Term Exam Semester 2 46. The best way to enforce this rule is by using: Mark for Review (1) Points A datatype of NUMBER(7. The following trigger has been created: CREATE TRIGGER upd_emp_trigg AFTER UPDATE ON employees FOR EACH ROW BEGIN A user now executes: UPDATE employees SET department_id = 50 WHERE department_id = 90.

Mid Term Exam Semester 2 . With which kind of trigger can the :OLD and :NEW qualifiers be used? Mark for Review (1) Points DDL triggers Database Event triggers Statement triggers Row triggers (*) AFTER triggers Correct Page 10 of 10 Skip navigation elements to page contents Test: Mid Term Exam Semester 2 Review your answers. Examine the following code.Line A BEGIN . what code should be included at Line A? CREATE TRIGGER dept_trigg AFTER UPDATE OR DELETE ON departments -. Refer to Section 10.. and question scores below. An asterisk (*) indicates a correct answer.True False (*) Incorrect. feedback. To create a row trigger. 49.. Mark for Review (1) Points AFTER EACH ROW FOR EVERY ROW FOR EACH ROW (*) ON EACH ROW ON EVERY ROW Correct 50.

DROP TRIGGER emp_trigg. Which dictionary view shows the detailed code of a Mark for Review trigger body? (1) Points USER_SOURCE USER_TRIGGERS USER_OBJECTS USER_DML_TRIGGERS (*) USER_SUBPROGRAMS Correct Correct 43. Which of the following will remove a trigger in your schema named EMP_TRIGG from the database? Mark for Review (1) Points DROP emp_trigg TRIGGER. (*) REMOVE TRIGGER emp_trigg. None of the above Correct Correct 42. Which one of the following can NOT be part of a Mark for Review Package ? (1) Points Procedures Explicit cursors Triggers (*) . ALTER TRIGGER emp_trigg DISABLE.41.

It does not matter which is created first. We can create packages without needing any system privileges 4. B and D (*) A.Functions Global variables Correct Correct Which of the following are good reasons for creating 44. We can declare INDEX BY tables and use them as parameters Mark for Review (1) Points A and B A. B. the specification or the body? Mark for Review (1) Points The body The specification (*) The specification and body must be created at the same time. Which part of a package must be created first. Related procedures. . We can recompile the package body without having to recompile the specification 3. C and D Incorrect Incorrect. Refer to Section 9. B and C A and C A. functions and variables can be grouped together as a single unit 2. and using Packages? 1. 45.

PUT_LINE can be invoked from inside a private packaged function. An asterisk (*) indicates a correct answer. but only if the package has no specification. True or False? Mark for Review (1) Points True (*) False Correct Correct 48.The body can be created first. DBMS_OUTPUT. Triue or False? Mark for Review (1) Points True (*) False Correct Correct 47. feedback. Mid Term Exam Semester 2 46. and question scores below. Every subprogram which has been declared in a package specification must also be included in the package body. Correct Previous Correct Page 9 of 10 Next Summary Skip navigation elements to page contents Test: Mid Term Exam Semester 2 Review your answers. Which of the following exceptions can be raised ONLY when using the UTL_FILE package? (Choose two) Mark for Review (1) Points (Choose all correct answers) INVALID_PATH NO_DATA_FOUND (*) VALUE_ERROR .

An Oracle directory called FILESDIR has been created by executing: CREATE OR REPLACE DIRECTORY filesdir AS 'C:\NEWFILES'.'c'). Why is it better to use DBMS_OUTPUT only in anonymous blocks.'w').'EMP_REPORT. Correct Correct 50.TXT'.'w').TXT').'EMP_REPORT. UTL_FILE.CREATE('FILESDIR'. while procedures do not display anything until their execution has finished Because DBMS_OUTPUT should be used only for testing and debugging PL/SQL code (*) Because DBMS_OUTPUT can raise a NO_DATA_FOUND exception if used inside a packaged procedure Correct Correct . not inside stored subprograms such as procedures? Review (1) Points Because DBMS_OUTPUT cannot be used inside procedures Mark for Because anonymous blocks display messages while the block is executing.READ_ERROR (*) E_MYEXCEP Incorrect Incorrect 49.FOPEN('C:\NEWFILES\EMP_REPORT.FOPEN('FILESDIR'.TXT'.TXT ? Mark for Review (1) Points UTL_FILE. UTL_FILE. Which of the following will create a new text file called C:\NEWFILES\EMP_REPORT.OPEN('FILESDIR'. (*) UTL_FILE.TXT'.'EMP_REPORT.

True or False? Mark for Review (1) Points . Mid Term Exam Semester 2 36...Previous Page 10 of 10 Summary Skip navigation elements to page contents Test: Mid Term Exam Semester 2 Review your answers. INSTEAD OF triggers are always row triggers. To create a row trigger. and question scores below. Mark for Review (1) Points AFTER EACH ROW FOR EVERY ROW FOR EACH ROW (*) ON EACH ROW ON EVERY ROW Correct Correct 37. the new value can immediately be seen by other sessions. feedback. even if FOR EACH ROW is omitted. True or False? Mark for Review (1) Points True (*) False Correct Correct 38. Examine the following code. what code should be included at Line A? CREATE TRIGGER dept_trigg AFTER UPDATE OR DELETE ON departments -. An asterisk (*) indicates a correct answer.Line A BEGIN . When a user session changes the value of a package variable.

What will happen when order shown? curspack.openproc. curspack. An error will occur at line 4. END. The package contains three public procedures: OPENPROC opens the cursor. MARY and JOE's schemas each contain an EMPLOYEES table. FETCHPROC fetches 5 rows from the cursor's active set. JOE creates the following trigger: CREATE TRIGGER upd_trigg AFTER DELETE ON joe.openproc. then the first 5 rows will be fetched again. An error will occur at line 2. What object privileges will TOM and JOE need? Mark for Review .line 1 -. curspack. curspack. CLOSEPROC closes the cursor.line 3 -.line 2 -.True False (*) Correct Correct 39.line 5 -. The first 5 rows will be fetched three times. curspack. A third user TOM needs to delete rows from JOE's EMPLOYEES table.fetchproc.line 6 The first 15 rows will be fetched.fetchproc.employees FOR EACH ROW BEGIN DELETE FROM mary. curspack. Mark for Review (1) Points a user session executes the following commands in the -.fetchproc.employee_id.closeproc.employees WHERE employee_id = :OLD. Package CURSPACK declares a global cursor in the package specification.line 4 -. The first 10 rows will be fetched. (*) Correct Correct 40.

but TOM needs DELETE on MARY.(1) Points TOM does not need any object privileges. SYSDATE). CREATE TRIGGER emp_trigg -.EMPLOYEES TOM needs DELETE on MARY. and question scores below. An asterisk (*) indicates a correct answer.UPD_TRIGG Correct Previous Correct Page 8 of 10 Next Summary Skip navigation elements to page contents Test: Mid Term Exam Semester 2 Review your answers. Mid Term Exam Semester 2 31.EMPLOYEES and MARY.EMPLOYEES TOM needs DELETE on JOE. feedback.EMPLOYEES (*) JOE does not need any object privileges.Line A BEGIN END. Examine the following code: INSERT INTO log_table VALUES (USER. but JOE needs DELETE on both TOM. Which of the following can NOT be coded at Line A? Mark for Review (1) Points BEFORE UPDATE ON employees AFTER INSERT OR DELETE ON employees AFTER SELECT ON employees (*) BEFORE DELETE ON employees AFTER UPDATE OF last_name ON employees .EMPLOYEES and JOE needs DELETE on MARY.EMPLOYEES and JOE needs EXECUTE on TOM.

What is wrong with the following code? CREATE OR REPLACE TRIGGER loc_trigg BEFORE DELETE ON locations BEGIN RAISE_APPLICATION_ERROR(-20201. Mark for Review (1) Points True False (*) . this trigger will compile and execute successfully. 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. You cannot use RAISE_APPLICATION_ERROR inside a trigger. END. The second line should be: BEFORE DELETE OF locations You cannot use ROLLBACK inside a trigger. Correct Correct 33.Correct Correct 32.'Invalid ROLLBACK. END. (*) Nothing is wrong. Mark for Review (1) Points The last line should be: END loc_trigg.'Deleting salary is not allowed'). delete').

END IF. Which of the following can NOT be coded in the body of a DML trigger? (Choose two. It should raise an user tries to update an employee's last name.Correct Correct 34. application error if a should allow updates to should be coded at line Examine the following trigger.Line A RAISE_APPLICATION_ERROR(-20201. What A? CREATE TRIGGER stop_ln_trigg BEFORE UPDATE ON employees BEGIN -. END. Mark for Review (1) Points IF UPDATING LAST_NAME THEN IF UPDATING('LAST_NAME') THEN (*) IF UPDATE('LAST_NAME') THEN IF UPDATING THEN Correct Correct 35.'Updating last name not allowed').) Mark for Review (1) Points (Choose all correct answers) IF DELETING THEN IF SELECTING THEN (*) IF INSERTING THEN IF UPDATING ('JOB_ID') THEN IF OTHERS THEN (*) Correct Correct . It all other columns of the EMPLOYEES table.

Mid Term Exam Semester 2 26. Which of the following are NOT stored inside the database? (Choose two. (*) Correct Correct 27.Previous Page 7 of 10 Next Summary Skip navigation elements to page contents Test: Mid Term Exam Semester 2 Review your answers. Do not use a trigger to replace or duplicate something which the Oracle Server does automatically.) Which of the following are good guidelines to follow Mark for Review (Choose all correct answers) Where possible. (1) Points when creating a database trigger? (Choose two. and question scores below. feedback. use a trigger to enforce a foreign key constraint. Do not create a trigger that automatically fires another trigger. Use triggers to override privilege checking and view other users' private tables. (*) Use triggers to prevent unauthorized users from SELECTing confidential data.) Mark for Review (1) Points (Choose all correct answers) A PL/SQL package specification A database trigger An anonymous block (*) An application trigger (*) A sequence . An asterisk (*) indicates a correct answer.

SYSDATE).1 WHERE department_id = 50. 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.99 or less than 0. The best way to enforce this rule is by using: Mark for Review (1) Points A datatype of NUMBER(7. A user now executes: UPDATE employees SET salary = salary * 1. A business rule states that an employee's salary cannot be greater than 99. How many rows will be inserted into audit_table? Mark for Review .999. True or False? Mark for Review (1) Points True (*) False Correct Correct 30. END.2) for the SALARY column A database trigger A check constraint (*) An application trigger A view Correct Correct 29.Correct Correct 28. You can use a trigger to prevent rows from being deleted from the EMPLOYEES table on Mondays.

p2 IN NUMBER).subprog('Jane'.30).param2=>30). END ol_pack. An asterisk (*) indicates a correct answer.subprog(param1=>'Jane'. (*) v_number := ol_pack. Examine the following package code: CREATE OR REPLACE PACKAGE ol_pack IS PROCEDURE subprog (p1 IN VARCHAR2. Which of the following calls will be successful? (Choose two. and question scores below. FUNCTION subprog (param1 IN VARCHAR2.(1) Points One (*) Two Five Six None of the above Correct Previous Correct Page 6 of 10 Next Summary Skip navigation elements to page contents Test: Mid Term Exam Semester 2 Review your answers. (*) Correct Correct . param2 IN NUMBER). feedback. PROCEDURE subprog (param1 IN CHAR.) Mark for Review (1) Points (Choose all correct answers) ol_pack. v_date := ol_pack. Mid Term Exam Semester 2 21. ol_pack. param2 IN NUMBER) RETURN DATE.subprog('Jane'.subprog(p1=>'Jane').30).

A PL/SQL subprogram that executes automatically whenever an associated database event occurs. True or False? Mark for Review (1) Points True False (*) Correct Correct 24. You can code COMMIT and ROLLBACK statements in a trigger body. PROCEDURE myproc (p1 NUMBER. PROCEDURE myproc (p1 NUMBER. PROCEDURE myproc (p1 NUMBER). PROCEDURE myproc (p1 VARCHAR2.22. . Which of the following best describes a database Mark for Review trigger? (1) Points A subprogram that checks whether a user has typed the correct password to log on to the database. 2. 4. Mark for Review (1) Points 1 and 2 1 and 3 (*) 2 and 3 3 and 4 1 and 4 Correct Correct 23. Which two of these declarations cannot be in the same package specification? 1. p2 VARCHAR2). p2 CHAR). (*) A PL/SQL subprogram that always returns exactly one value. p2 NUMBER). 3.

(*) SELECT func1(100) FROM dual.a function FUNC1 . A PL/SQL subprogram that inserts rows into a logging table. Which of the following calls to these objects (from an anonymous block) are correct? (Choose two.packfunc(40) THEN . Refer to Section 10.. Correct Correct 25. An asterisk (*) indicates a correct answer. and question scores below.a trigger TRIGG1. trigg1. Package OLDPACK is in your schema.. and the functions return BOOLEANs. Mark for Review (1) Points .. What will happen when the following statement is executed? DROP PACKAGE oldpack.A package PACK1 which contains a public procedure PACKPROC and a private function PACKFUNC . (*) Incorrect Previous Incorrect. IF pack1.A subprogram that is invoked explicitly by the calling application.packproc(25). Mid Term Exam Semester 2 16. The following objects have been created in a user's schema: .. feedback. IF func1(75) THEN . Page 5 of 10 Next Summary Skip navigation elements to page contents Test: Mid Term Exam Semester 2 Review your answers.) Mark for Review (1) Points (Choose all correct answers) pack1. The procedure and functions each accept a single IN parameter of type NUMBER.

You have also been granted privileges to access three packages (and their bodies) in other users' schemas. Correct Correct 17. each having a specification and a body. The specification will be dropped but the body will be retained. The package body of TAXPACK also includes a function called TAXFUNC. Your schema contains four packages. Mark for Review (1) Points 14 7 3 6 (*) 0 Correct Correct 18. PROCEDURE END mypack. Examine the following package specification: CREATE OR REPLACE PACKAGE taxpack IS CURSOR empcurs IS SELECT * FROM employees. What will be displayed by the following query? SELECT COUNT(*) FROM ALL_OBJECTS WHERE object_type LIKE 'PACK%' AND owner <> USER.The body will be dropped but the specification will be retained. Which one of the following statements is NOT true? Mark for Review (1) Points . Both the specification and the body will be dropped. (*) The statement will fail because you must drop the body before you can drop the specification. taxproc.

1 WHERE department_id = p_deptno. Package HRPACK contains the following public function: FUNCTION empfunc (p_deptno NUMBER) RETURN NUMBER IS BEGIN UPDATE employees SET salary = salary * 1. (*) . hrpack. The SELECT will succeed because it is referencing a different table from the function. The SELECT will fail because you cannot execute a DML statement from within a query.taxproc.The procedure can be invoked by: BEGIN taxpack. END empfunc. Mark for Review (1) Points The SELECT will fail because you cannot return SQL%ROWCOUNT from a function. What will happen when the following SQL statement is executed? SELECT department_name. END. (*) TAXPROC is a public procedure and TAXFUNC is a private function TAXPROC can invoke TAXFUNC if TAXPROC is coded before TAXFUNC TAXPROC can open the cursor Correct Correct 19. The packaage will not compile because you cannot declare a cursor in the specification. RETURN SQL%ROWCOUNT.empfunc(department_id) FROM departments. packaged The SELECT will fail because you cannot call packaged functions from within a SQL statement.

p_salary IN NUMBER). ELSE RETURN TRUE. END IF. Nothing is needed at Line A Correct Previous Correct Page 4 of 10 Next Summary Skip navigation elements to page contents Test: Mid Term Exam Semester 2 Review your answers. CREATE OR REPLACE PACKAGE BODY emppack IS -. feedback. p_salary IN NUMBER). p_salary IN NUMBER) IS BEGIN IF NOT sal_ok(p_salary) THEN RAISE_APPLICATION_ERROR(-20201. FUNCTION sal_ok(pf_salary NUMBER) RETURN BOOLEAN IS BEGIN IF pf_salary > 50000 THEN RETURN FALSE. and question scores below. FUNCTION sal_ok(pf_salary NUMBER) RETURN BOOLEAN. Mid Term Exam Semester 2 11. END sal_ok. END IF. FUNCTION sal_ok(pf_salary NUMBER). A SQL statement can pass through several stages.Line A PROCEDURE upd_emp (p_empno IN NUMBER.Correct Correct 20. END emppack. END upd_emp. An asterisk (*) indicates a correct answer. END emppack.'Invalid salary'). Which of the following is NOT one of these stages? Mark for Review (1) Points . What must be coded at Line A for this package to compile successfully? Mark for Review (1) Points FUNCTION sal_ok. (*) PROCEDURE upd_emp (p_empno IN NUMBER. Examine the following code: CREATE OR REPLACE PACKAGE emppack IS PROCEDURE upd_emp (p_empno IN NUMBER.

CREATE OR REPLACE PACKAGE BODY varpack IS -.Point B PROCEDURE varproc IS -.BIND FETCH PARSE RETURN (*) EXECUTE Correct Correct 12.Point A END varpack. True or False? Mark for Review (1) Points True False (*) Correct Correct 13. In the following code. both the specification and the body must be recompiled. When a change is made to the detailed code of a public procedure in a package (but not to the procedure's name or parameters). PROCEDURE . Mark for Review (1) Points . -. where should MYVAR be declared? CREATE OR REPLACE PACKAGE varpack IS -..Point D END varpack. We need to declare a package variable named MYVAR.Point C BEGIN END varproc. which can be referenced by any subprogram in the package but can NOT be referenced from outside the package..

Which one of the following statements is true? Mark for Review .Point A Point B (*) Point C Point D Point B or Point C. SELECT text FROM USER_SOURCE WHERE name = 'DEPTPACK' AND type = 'PACKAGE BODY' ORDER BY line. (*) SELECT text FROM USER_SOURCE WHERE object_name = 'DEPTPACK' AND object_type = 'PACKAGE BODY' ORDER BY line. they will both work Correct Correct 14. SELECT text FROM USER_SOURCE WHERE name = 'DEPTPACK' AND type = 'BODY' ORDER BY line. Correct Correct 15. A package contains both public and private subprograms. Which of the following will display the detailed code of the subprograms in package DEPTPACK in your schema ? Mark for Review (1) Points SELECT text FROM USER_SOURCE WHERE name = 'DEPTPACK' AND type = 'PACKAGE' ORDER BY line.

All of the above are allowed.Line A END. feedback. The public subprograms are all loaded into memory at the same time. (*) DBMS_OUTPUT. .(1) Points Each subprogram is loaded into memory when it is first invoked. SELECT count(*) INTO v_count FROM employees. and question scores below. Which of the following statements is NOT allowed at Line A? Mark for Review (1) Points SELECT count(*) INTO v_count FROM departments. An asterisk (*) indicates a correct answer. (*) If three users invoke three different subprograms in the package. Correct Previous Correct Page 3 of 10 Next Summary Skip navigation elements to page contents Test: Mid Term Exam Semester 2 Review your answers. but the private subprograms are loaded into memory one at a time as they are invoked.PUT_LINE('A salary was updated'). there will be three copies of the code in memory.employee_id. The whole package is loaded into memory when the first call is made to any subprogram in the package. None. Examine the following code: CREATE TRIGGER emp_trigg AFTER UPDATE OF salary ON employees FOR EACH ROW DECLARE v_count NUMBER. UPDATE employees SET job_id = 'IT_PROG' WHERE employee_id = :OLD. Mid Term Exam Semester 2 6. BEGIN -.

'Invalid END.Incorrect Incorrect. Only the first time the procedure is executed. You want to prevent any objects in your schema from being altered or dropped. 7. A public packaged procedure contains the following Mark for Review SQL statement: UPDATE employees SET salary = salary * 1.Line A BEGIN RAISE_APPLICATION_ERROR(-20203.1. DROP ON SCHEMA AFTER ALTER. Refer to Section 10. Correct Correct 8. You decide to create the following trigger: CREATE TRIGGER stop_ad_trigg -. When the package is loaded into memory. What should you code at Line A ? Mark for Review (1) Points AFTER ALTER OR DROP ON SCHEMA INSTEAD OF ALTER OR DROP ON SCHEMA BEFORE ALTER OR DROP ON SCHEMA (*) BEFORE ALTER. When is this SQL statement parsed? (1) Points When the package specification is created When the package body is created (*) When the package header is loaded into memory. DROP ON SCHEMA Operation'). .

The procedure will raise an exception because one of the views is a complex view. The following procedure adds a column of datatype DATE to the EMPLOYEES table.. END LOOP. BEGIN FOR v_curs_rec IN c_curs LOOP EXECUTE IMMEDIATE 'DROP VIEW ' || v_curs_rec. The name of the new column is passed to the procedure as a parameter. END. Which of the following will work correctly when coded at line A? (Choose two.view_name. Correct Correct 10..) Mark for Review (1) Points (Choose all correct answers) v_first_string || p_col_name || v_second_string. . The procedure will raise an exception because Dynamic SQL can drop tables but cannot drop views.Correct Correct 9. CREATE OR REPLACE PROCEDURE addcol (p_col_name IN VARCHAR2) IS v_first_string VARCHAR2(100) := 'ALTER TABLE EMPLOYEES ADD ('. Line A END. BEGIN . What will happen when this procedure is invoked? Mark for Review (1) Points All views in the user's schema will be dropped. Examine the following code: CREATE OR REPLACE PROCEDURE myproc IS CURSOR c_curs IS SELECT view_name FROM user_views. v_second_string VARCHAR2(6) := ' DATE)'. (*) The procedure will not compile successfully because the syntax of EXECUTE IMMEDIATE is incorrect.

EXECUTE IMMEDIATE 'v_first_string' || p_col_name || 'v_second_string'. An asterisk (*) indicates a correct answer..EXECUTE (*) IMMEDIATE v_first_string || p_col_name || v_second_string.. feedback. Mid Term Exam Semester 2 1. and question scores below. Which of the following can be used in place of reserved_word? (Choose two. v_first_string := v_first_string || p_col_name.) Mark for Review (1) Points (Choose all correct answers) TABLE SCHEMA (*) USER DATABASE (*) TABLE employees . Examine this code: CREATE TRIGGER new_trigg AFTER CREATE ON reserved_word BEGIN . EXECUTE (*) EXECUTE v_first_string || p_col_name || v_second_string. IMMEDIATE v_first_string || v_second_string. Correct Previous Correct Page 2 of 10 Next Summary Skip navigation elements to page contents Test: Mid Term Exam Semester 2 Review your answers.

The CALL statement must not end with a semicolon (. TRUNCATE TABLE locations. All of the above (*) Correct Correct 3.) All of the above (*) Correct Correct 4. Mark for Review (1) Points You cannot code an AFTER LOGOFF trigger When using CALL.2)). you must not code END. END. Examine this code: CREATE TRIGGER de_trigg . What is wrong with the following code? CREATE TRIGGER call_trigg AFTER LOGOFF ON SCHEMA BEGIN CALL drop_proc. ALTER TABLE departments ADD (budget NUMBER(8. Which of the following statements could cause a DDL Mark for Review trigger to fire? (1) Points DROP TABLE employees. CREATE TABLE newemp AS SELECT * FROM employees. you must not code BEGIN When using CALL.Correct Correct 2.

Line A BEGIN .) Mark for Review (1) Points (Choose all correct answers) AFTER LOGOFF ON SCHEMA (*) AFTER LOGON ON SCHEMA BEFORE LOGOFF ON SCHEMA BEFORE DISCONNECT ON SCHEMA (*) AFTER SERVERERROR ON SCHEMA Correct Correct 5...-. Which of the following are NOT valid at Line A ? (Choose two. problem? (Choose two.) (1) Points Which kinds of trigger can cause a mutating table Mark for Review (Choose all correct answers) BEFORE UPDATE row triggers (*) DDL triggers AFTER DELETE row triggers (*) Database Event triggers INSTEAD OF triggers Correct Page 1 of 10 Correct Next Summary .

and question scores below. The following package specification has been created: CREATE OR REPLACE PACKAGE mypack IS FUNCTION myfunc(p_funcparam DATE) RETURN BOOLEAN. Which of the following statements about packages is NOT true ? Mark for Review (1) Points All procedures and functions must be declared in the specification. Which of the following will correctly invoke the package subprograms? (Ch oose two.myfunc('22-JAN-07'). Section 9 1. PROCEDURE myproc(p_procparam IN NUMBER). The body contains the detailed code of the subprograms.) Mark for Review (1) Points (Choose all correct answers) mypack. END mypack. An asterisk (*) i ndicates a correct answer. Variables can be declared in the body. feedback. Correct 2. (*) Cursors can be declared in the specification. . The specification must be created before the body.Test: Mid Term Exam Semester 2 Review your answers.

Correct 3. v_num := mypack. (*) IF NOT mypack. (*) myproc(40).myproc(22). Which one of the following can NOT be part of a Package ? Mark for Review (1) Points Procedures Explicit cursors Triggers (*) Functions Global variables Correct 4. What is wrong with the following syntax for creating a package specific ation? CREATE OR REPLACE PACKAGE mypack IS .PUT_LINE('Message').myfunc(SYSDATE) THEN DBMS_OUTPUT. END IF.myproc(35).mypack.

FUNCTION func1 (p_param1 IN VARCHAR2). END mypack. It is an anonymous block at the end of a package body. . (*) The first line should be: CREATE OR REPLACE PACKAGE SPECIFICATION mypack IS Nothing is wrong. Which of the following statements about a package initialization block is true? Mark for Review (1) Points It cannot contain any SQL statements. The RETURN datatype of the functions must be specified. Mark for Review (1) Points You cannot declare constants in the specification. A package must contain at least one procedure. FUNCTION func2. (*) It is a procedure in a package that must be invoked before the rest of the package can be used. this code contains no errors. It is an anonymous block in the package specification.g_constant1 NUMBER(6) := 100. Correct 5.

hrpack. (*) Correct 7. Package HRPACK contains the following public function: FUNCTION empfunc (p_deptno NUMBER) RETURN NUMBER IS BEGIN UPDATE employees SET salary = salary * 1. How would you do this? . RETURN SQL%ROWCOUNT. The value of the tax rate is stored in table TAXTAB in the database. Mark for Review (1) Points The SELECT will fail because you cannot return SQL%ROWCOUNT from a packaged function. Correct 6.empfunc(department_id) FROM departments.1 WHERE department_id = p_deptno. Package TAXPACK declares a global variable G_TAXRATE NUMBER(2.2) . The SELECT will fail because you cannot call packaged functions from w ithin a SQL statement. END empfunc. What will happen when the following SQL statement is executed? SELECT department_name. You want to read this value automatically into G_TAXRATE each time a user session makes its first call to TAXPACK. 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.It is executed automatically every time any global variable in the package is referenced.

g_taxrate FROM taxtab.Point A . where should MYVAR be de clared? CREATE OR REPLACE PACKAGE varpack IS -. We never need to use a forward declaration when invoking a public su bprogram. (*) Correct 8. and invoke the function from the user session. In the following code. Add a package initialization block to the package body of TAXPACK. which can be r eferenced by any subprogram in the package but can NOT be referenced fr om outside the package. Create a database trigger that includes the following code: SELECT tax_rate INTO taxpack.Mark for Review (1) Points Declare the global variable as: g_taxrate NUMBER(2. True or False? Mark for Review (1) Points True (*) False Correct 9.2) := SELECT tax_rate FROM taxtab. Add a private function to the package body of TAXPACK. We need to declare a package variable named MYVAR.

Point D END varpack.Point C BEGIN END varproc.Point B PROCEDURE varproc IS -. -. True or False? Mark for Review (1) Points True (*) False Correct . CREATE OR REPLACE PACKAGE BODY varpack IS -. Mark for Review (1) Points Point A Point B (*) Point C Point D Point B or Point C.END varpack. In a package. PROCEDURE . they will both work Correct 10.. public components are declared in the specification but private components are not..

DROP PACKAGE bigpack SPECIFICATION. Which of the following will display the detailed code of the subp rograms in package DEPTPACK in your schema ? Mark for Review (1) Points SELECT text FROM USER_SOURCE WHERE name = 'DEPTPACK' AND type = 'PACKAGE' ORDER BY line. None of the above (*) Correct 12. and question scores below. DROP PACKAGE SPECIFICATION bigpack. We want to remove the specification (but not the body) of package BIGPACK from the database. An asterisk (*) i ndicates a correct answer. DROP PACKAGE HEADER bigpack. Which of the following commands will do this ? Mark for Review (1) Points DROP PACKAGE bigpack. feedback.Page 1 of 5 Test: Mid Term Exam Semester 2 Review your answers. Section 9 11. .

Mark for Review (1) Points The body will be dropped but the specification will be retained. (*) SELECT text FROM USER_SOURCE WHERE object_name = 'DEPTPACK' AND object_type = 'PACKAGE BODY'ORDER BY line. Correct 13. Correct . SELECT text FROM USER_SOURCE WHERE name = 'DEPTPACK' AND type = 'BODY' ORDER BY line. Package OLDPACK is in your schema. The specification will be dropped but the body will be retained. the Both specification and the body will be dropped.SELECT text FROM USER_SOURCE WHERE name = 'DEPTPACK' AND type = 'PACKAGE BODY' ORDER BY line. (*) The statement will fail because you must drop the body before you can dro p the specification. What will happen when the fol lowing statement is executed? DROP PACKAGE oldpack.

(*) TAXPROC is a public procedure and TAXFUNC is a private function TAXPROC can invoke TAXFUNC if TAXPROC is coded before TAXF UNC TAXPROC can open the cursor Correct 15. From where can PRIVFUNC be invoked? (Choose two. Which one of the following statements is NOT true? Mark for Review (1) Points The procedure can be invoked by: BEGIN taxpack. The package body of TAXPACK also includes a function called TAXFUNC. END mypack.) Mark for Review (1) Points (Choose all correct answers) From an anonymous block . PROCEDURE taxproc.taxproc. The packaage will not compile because you cannot declare a cursor in the specification. Examine the following package specification: CREATE OR REPLACE PACKAGE taxpack IS CURSOR empcurs IS SELECT * FROM employees. Package NEWPACK contains several procedures and functions. inc luding private function PRIVFUNC. END.14.

From any procedure in NEWPACK (*) From any private function in another package From any function in NEWPACK (*) From any public procedure in another package Correct 16. The DBMS_OUTPUT. Which of the following best describes the purpose of the UTL_FILE package? Mark for Review (1) Points It is used to load binary files such as employees' photos into the database.PUT procedure places text in a buffer but does not display the contents of the buffer. (*) It is used to find out how much free space is left on an operating system di sk. Correct . It is used to query CHAR and VARCHAR2 columns in tables. True or False? Mark for Review (1) Points True (*) False Correct 17. It is used to read and write text files stored outside the database.

RETURN TRUE. Why is it better to use DBMS_OUTPUT only in anonymous blocks. The UTL_FILE package can be used to create binary files such as JPEG s as well as text files. You write the follo wing code: CREATE OR REPLACE FUNCTION droptab (p_tab_name IN VARCHAR2) RETURN BOOLEAN IS BEGIN DROP TABLE p_tab_name. True or False? Mark for Review (1) Points True False (*) Correct 20. EXCEPTION . You want to create a function which drops a table. while procedures do not display anything until their execution has finishe d Because DBMS_OUTPUT should be used only for testing and debugging PL/SQL code (*) Because DBMS_OUTPUT can raise a NO_DATA_FOUND exception if use d inside a packaged procedure Correct 19.18. no t inside stored subprograms such as procedures? Mark for Review (1) Points Because DBMS_OUTPUT cannot be used inside procedures Because anonymous blocks display messages while the block is executing.

An asterisk (*) i ndicates a correct answer. MARY wants HENRY to be able to query her EMPLOYEES table. Why will this procedure not compile successfully? Mark for Review (1) Points Because you can never drop a table from inside a function Because the PL/SQL compiler cannot check if the argument of p_tab_name a is valid table-name (*) Because you do not have the privilege needed to drop a table Because you cannot use RETURN in the exception section Correct Page 2 of 5 Test: Mid Term Exam Semester 2 Review your answers. feedback. Section 9 21. . BEGIN v_grant_stmt := 'GRANT SELECT ON employees TO henry'. and question scores below. DBMS_SQL. Mary executes the following code: DECLARE v_grant_stmt VARCHAR2(50).EXECUTE(v_grant_stmt).WHEN OTHERS THEN RETURN FALSE. END. END.

Correct 23.Mary has successfully granted the privilege to Henry. BEGIN FOR v_curs_rec IN c_curs LOOP EXECUTE IMMEDIATE 'DROP VIEW ' || v_curs_rec. The procedure will raise an exception because one of the views is a comp lex view. The easiest way to include DDL statements in a PL/SQL block is to use the DBMS_SQL package. END. True or False? Mark for Review (1) Points True False (*) Correct 22. The procedure will raise an exception because Dynamic SQL can drop tab les but cannot drop views.view_name. True or False? Mark for Review . Examine the following code: CREATE OR REPLACE PROCEDURE myproc IS CURSOR c_curs IS SELECT view_name FROM user_views. END LOOP. 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 not compile successfully because the syntax of E XECUTE IMMEDIATE is incorrect.

What values will Dick and Hazel see? Mark for Review (1) Points Dick: 45.g_myvar := 45.g_myvar).PUT_LINE(multipack.(1) Points True False (*) Correct 24.PUT_LINE si incorrect Correct 25. END. Hazel: 0 Dick: 45. User HAZEL now connects to the database. the new . Both users immediately execute : BEGIN DBMS_OUTPUT. Package MULTIPACK declares the following global variable: g_myvar NUMBER. Hazel: 0 Both queries will fail because the syntax of DBMS_OUTPUT. Hazel: 45 Dick: 45. When a user session changes the value of a package variable. User DICK executes the following: multipack. Hazel: null (*) Dick: 0.

True or False? Mark for Review (1) Points True (*) False . INSTEAD OF triggers are always row triggers.. In the following code: CREATE TRIGGER mytrigg INSTEAD OF INSERT OR UPDATE ON my_object_name FOR EACH ROW BEGIN .value can immediately be seen by other sessions. True or False? Mark for Review (1) Points True False (*) Correct 27. even if FOR EACH RO W is omitted. True or False? Mark for Review (1) Points True False (*) Correct Section 10 26. my_object_name can be the name of a table..

JOE cre . Which of the following can NOT be coded in the body of a DML trig ger? (Choose two. With which kind of trigger can the :OLD and :NEW qualifiers be use d? Mark for Review (1) Points DDL triggers Database Event triggers Statement triggers Row triggers (*) AFTER triggers Correct 30.Correct 28. MARY and JOE's schemas each contain an EMPLOYEES table.) Mark for Review (1) Points (Choose all correct answers) IF DELETING THEN IF SELECTING THEN (*) IF INSERTING THEN IF UPDATING ('JOB_ID') THEN IF OTHERS THEN (*) Correct 29.

Section 10 .ates the following trigger: CREATE TRIGGER upd_trigg AFTER DELETE ON joe. END.EMPLOYEES TOM needs DELETE on MARY. An asterisk (*) i ndicates a correct answer.employees WHERE employee_id = :OLD. and question scores below. A third user TOM needs to delete rows from JOE's EMPLOYEES table.employee_id.EMPLOYEES and JOE needs EXECU TE on TOM. Wha t object privileges will TOM and JOE need? Mark for Review (1) Points TOM does not need any object privileges.employees FOR EACH ROW BEGIN DELETE FROM mary.UPD_TRIGG Correct Page 3 of 5 Test: Mid Term Exam Semester 2 Review your answers.EMPLOYEES (*) JOE does not need any object privileges. but TOM needs DELETE on MARY. feedback. but JOE needs DELE TE on both TOM.EMPLOYEES TOM needs DELETE on JOE.EMPLOYEES and JOE needs DELETE on MARY.EMPLOYEES and MARY.

AYSEGUL now tries to drop the LOCATIONS table.. What happens? Mark for Review (1) Points An error message is displayed because you cannot drop a table that is asso ciated with a trigger. The table is dropped and the trigger is disabled. ALTER TABLE departments DROP ALL TRIGGERS. You need to disable all triggers that are associated with DML st atements on the DEPARTMENTS table. Which of the following commands shou ld you use? Mark for Review (1) Points ALTER TABLE departments DISABLE ALL TRIGGERS.locations BEGIN .31. Both the table and the trigger are dropped. The trigger is dropped but the table is not dropped.. (*) ALTER TRIGGER DISABLE ALL ON departments. ALTER TABLE departments DISABLE TRIGGERS. DISABLE ALL TRIGGERS ON departments. User AYSEGUL successfully creates the following trigger: CREATE TRIGGER loc_trigg BEFORE UPDATE ON aysegul. Correct . (*) None of the above. Correct 32.

). You decide to create the following trigger: CREATE TRIGGER stop_ad_trigg -.. What should the DBA code at Line A ? Mark for Review (1) Points AFTER ERROR ON DATABASE AFTER SERVER ERROR ON DATABASE AFTER SERVERERROR ON SCHEMA AFTER SERVERERROR ON DATABASE (*) AFTER ORACLE ERROR ON SCHEMA Correct 34.'Invalid Operation'). The DBA creates the follow ing trigger: CREATE TRIGGER log_errs_trigg -. You want to prevent any objects in your schema from being altered or dropped. What should you code at Line A ? Mark for Review (1) Points AFTER ALTER OR DROP ON SCHEMA INSTEAD OF ALTER OR DROP ON SCHEMA .Line A BEGIN INSERT INTO errlog_table VALUES (..33. The database administrator wants to write a log record every time an Oracle Server error occurs in any user's session.Line A BEGIN RAISE_APPLICATION_ERROR(-20203. END. END.

DROP ON SCHEMA Correct 35. ... Examine this code: CREATE TRIGGER de_trigg -.BEFORE ALTER OR DROP ON SCHEMA (*) BEFORE ALTER. Which of the following statements could cause a DDL trigger to fire? Mark for Review (1) Points DROP TABLE employees. DROP ON SCHEMA AFTER ALTER. Which of the following are NOT valid at Line A ? (Choose two.Line A BEGIN .) Mark for Review (1) Points (Choose all correct answers) AFTER LOGOFF ON SCHEMA (*) AFTER LOGON ON SCHEMA BEFORE LOGOFF ON SCHEMA BEFORE DISCONNECT ON SCHEMA (*) AFTER SERVERERROR ON SCHEMA Correct 36.

) Mark for Review (1) Points (Choose all correct answers) TABLE SCHEMA (*) USER DATABASE (*) TABLE employees Correct 38. CREATE TABLE newemp AS SELECT * FROM employees. Which kinds of trigger can cause a mutating table problem? (Choose two. Which of the following can be used in place of reserved_word? (Choose two . Examine this code: CREATE TRIGGER new_trigg AFTER CREATE ON reserved_word BEGIN .) Mark for Review (1) Points .2)).. All of the above (*) Correct 37. TRUNCATE TABLE locations.ALTER TABLE departments ADD (budget NUMBER(8..

Examine the following code: CREATE TRIGGER emp_trigg AFTER UPDATE OF salary ON employees FOR EACH ROW DECLARE v_count NUMBER. SELECT count(*) INTO v_count FROM employees. All of the above are allowed. salary was updated').PUT_LINE('A None.employee_id.(Choose all correct answers) BEFORE UPDATE row triggers (*) DDL triggers AFTER DELETE row triggers (*) Database Event triggers INSTEAD OF triggers Correct 39.Line A END. (*) DBMS_OUTPUT. BEGIN -. UPDATE employees SET job_id = 'IT_PROG' WHERE employee_id = : OLD. Which of the following statements is NOT allowed at Line A? Mark for Review (1) Points SELECT count(*) INTO v_count FROM departments. .

END. (*) Nothing is wrong.'Invalid ROLLBACK. Mark for Review (1) Points The last line should be: END loc_trigg. delete'). What is wrong with the following code? CREATE OR REPLACE TRIGGER loc_trigg BEFORE DELETE ON locations BEGIN RAISE_APPLICATION_ERROR(-20201.Correct 40. Correct Page 4 of 5 Test: Mid Term Exam Semester 2 . You cannot use RAISE_APPLICATION_ERROR inside a trigger. this trigger will compile and execute successfully. The second line should be: BEFORE DELETE OF locations You cannot use ROLLBACK inside a trigger.

42. but not when any other column of the EMPLOYEES table is updated. (*) You cannot use DBMS_OUTPUT. job_id) BEGIN . The second line should be: BEFORE UPDATE ON departments.. An asterisk (*) i ndicates a correct answer. Which of the following is the correct syntax to do this? Mark for Review (1) Points CREATE TRIGGER emp_upd_trigg AFTER UPDATE ON employees (salary. END.department_name Incorrect. feedback.PUT_LINE inside a trigger. Section 10 41.department_name). You cannot use :NEW or :OLD in a statement trigger. Refer to Section 10.PUT_LINE(:NEW. Mark for Review (1) Points You cannot use :NEW in a BEFORE trigger.Review your answers. . and question scores below. only in an AFTER trigger.. What is wrong with the following code? CREATE TRIGGER dept_trigg BEFORE UPDATE OF department_name ON departments BEGIN DBMS_OUTPUT. You need to create a trigger that will fire whenever an employee's s alary or job_id is updated.

Mark for Review (1) Points True False (*) Correct 44.'Deleting salary is not allowed') . 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. END.. Correct 43.CREATE TRIGGER emp_upd_trigg AFTER UPDATE OF salary.... (*) CREATE TRIGGER emp_upd_trigg AFTER UPDATE OF (salary. job_id) ON employees BEGIN . What type of database object would you create to write an auditing r ecord automatically every time a user connects to the database? Mark for R .. job_id ON employees BEGIN .. CREATE TRIGGER emp_upd_trigg AFTER UPDATE OF salary OR job_id ON employees BEGIN .

. (*) Correct ..a function FUNC1 ..) Mar k for Review (1) Points (Choose all correct answers) pack1. IF pack1. (*) SELECT func1(100) FROM dual. IF func1(75) THEN .. trigg1. The procedure and functions each accept a single IN parameter of type NU MBER.packfunc(40) THEN .a trigger TRIGG1.packproc(25).A package PACK1 which contains a public procedure PACKPROC and a private function PACKFUNC . Which of the following calls to these objects (from an anonymous block) are correct? (Choose two. and the functions return BOOLEANs.eview (1) Points A procedure A complex view A trigger (*) A function A package Correct 45. The following objects have been created in a user's schema: .

Do not create a trigger that automatically fires another trigger. (*) Correct 48.46. Use triggers to override privilege checking and view other users' private ta bles. You can use a trigger to prevent rows from being deleted from the EMPLOYEES table on Mondays. use a trigger to enforce a foreign key constraint. Which of the following are good guidelines to follow when creating a database trigger? (Choose two. (*) Use triggers to prevent unauthorized users from SELECTing confidential data. Which of the following are NOT stored inside the database? (Choose two.) Mark for Review (1) Points (Choose all correct answers) Where possible.) Mark for Review (1) Points (Choose all correct answers) . True or False? Mark for Review (1) Points True (*) False Correct 47. Do not use a trigger to replace or duplicate something which the Oracle S erver does automatically.

2) for the SALARY column A database trigger A check constraint (*) An application trigger A view Correct 50. Which of the following best describes a database trigger? Mark for R eview (1) Points A subprogram that checks whether a user has typed the correct password t o log on to the database. A PL/SQL subprogram that executes automatically whenever an associated .999.99 or less than 0. The best way to enforce this rule is by using: M ark for Review (1) Points A datatype of NUMBER(7.A PL/SQL package specification A database trigger An anonymous block (*) An application trigger (*) A sequence Correct 49. A business rule states that an employee's salary cannot be greater tha n 99.

(*) A PL/SQL subprogram that always returns exactly one value. A subprogram that is invoked explicitly by the calling application. A PL/SQL subprogram that inserts rows into a logging table.database event occurs. Correct Page 5 of 5 .

The PAYMENT table contains these columns: PAYMENT_ID NUMBER(9) PK PAYMENT_DATE DATE CUSTOMER_ID NUMBER(9) Which SELECT statement could you use to display the number of times each customer payment was made between January 1. . manager_id. You only want to include employees who earn more than 15000. 2003 ? SELECT customer_id. department_id FROM employees GROUP BY department_id. manager_id FROM employees GROUP BY department_id. COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003' GROUP BY customer_id. department_id. department_id HAVING AVG(salary) > 35000 ORDER BY department_id. Which SELECT statement should you use? SELECT location_id. 2003 and June 30. Which clause should you include in the SELECT statement? WHERE salary > 15000 Evaluate this SELECT statement: SELECT SUM(salary). COUNT(DISTINCT type) FROM manufacturer GROUP BY location_id. Evaluate this SELECT statement: SELECT COUNT(employee_id).Mid Term Exam Semester 2 Which statement about group functions is true? Group functions ignore null values. Which clauses restricts the result? WHERE job_id <> 69879 HAVING AVG(salary) > 35000 What is the correct order of clauses in a SELECT statement? SELECT FROM WHERE GROUP BY HAVING ORDER BY The MANUFACTURER table contains these columns: MANUFACTURER_ID NUMBER MANUFACTURER_NAME VARCHAR2(30) TYPE VARCHAR2(25) LOCATION_ID NUMBER You need to display the number of unique types of manufacturers at each location. AVG(salary) FROM employees WHERE job_id <> 69879 GROUP BY job_id. Evaluate this statement: SELECT department_id.

name. ONCE. id_number. True or False? True CUBE can be applied to all aggregate functions including AVG. the ORDER BY clause is used ______ and is placed in the _____ SELECT statement of the query.Which SELECT clause allows you to restrict the rows returned. SUM(salary) FROM employees WHERE salary > 25000 GROUP BY department_id. LAST When using SET operators the names of the columns must be identified in all of the SELECT statements used in the query.2) HIRE_DATE DATE Evaluate this SQL statement: SELECT id_number. SUM. MIN. True or False? False GROUPING SETS is another extension to the GROUP BY clause and is used to specify multiple groupings of data but provide a single result set. and COUNT. Why will this statement cause an error? The HIRE_DATE column is NOT included in the GROUP BY clause. True or False? True Which answer is incorrect? The parent statement can be: An INSERT statement . department_id. name ORDER BY hire_date. The Oracle server performs a correlated subquery when the subquery references a column from a table referred to in the parent. MAX. True or False? True You use ROLLUP to: produce subtotal values You use GROUPING function to: Identify the extra row values created by either a ROLLUP or CUBE operation Which statement is false? The WITH clause decreases performance. To control the order of rows returned using SET operators. based on a group function? HAVING SUM(salary) > 100000 Group functions can be nested to a depth of? Two The EMPLOYEES table contains these columns: ID_NUMBER NUMBER Primary Key NAME VARCHAR2 (30) DEPARTMENT_ID NUMBER SALARY NUMBER (7.

Which statement would you use? . salary FROM employees WHERE department_id = (SELECT department_id FROM employees WHERE last_name like '%u%') Single rather than multiple value operator used. Which SELECT statement should you use? SELECT product_name FROM products WHERE cost > (SELECT AVG(cost) FROM product). Which two SQL statements correctly use subqueries? SELECT * FROM class_assignments WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments). True or False? True If a single-row subquery returns a null value and uses the equality comparison operator. If you use the equality operator (=) with a subquery. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns: TEACHERS TEACHER_ID NUMBER(5) Primary Key NAME VARCHAR2 (25) SUBJECT_ID NUMBER(5) CLASS_ASSIGNMENTS CLASS_ID NUMBER (5) Primary Key TEACHER_ID NUMBER (5) DATE MAX_CAPACITY NUMBER (3) All MAX_CAPACITY values are greater than 10. Which comparison operator should you use? >= You need to create a report to display the names of products with a cost value greater than the average cost of all products. process the block just once. how many values can the subquery return? Only 1 You need to remove a row from the EMPLOYEES table. label the results. what will the outer query return? No rows Which comparison operator can only be used with a single-row subquery? <> Which of the following is a valid reason why the query below will not execute successfully? SELECT employee_id. and then refer to the results multiple times. SELECT * FROM teachers WHERE teacher_id = (SELECT teacher_id FROM teachers WHERE class_id = 45963). last_name. Which operator can be used with a multiple-row subquery? IN You need to display all the players whose salaries are greater than or equal to John Brown's salary.The WITH clause enables a SELECT statement to define the subquery block at the start of the query.

Primary Key SUPPLIER_NAME VARCHAR2 (25) ADDRESS VARCHAR2 (30) CITY VARCHAR2 (25) REGION VARCHAR2 (10) POSTAL_CODE VARCHAR2 (11) PRODUCTS PRODUCT_ID NUMBER NOT NULL. her last name is now Rockefeller. Which SQL statement will allow you to reflect this change? UPDATE my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189. manager_id. The EMPLOYEES table contains these columns and all data is stored in lowercase: EMPLOYEE_ID NUMBER(10) PRIMARY KEY LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) DEPARTMENT_ID VARCHAR2 (20) HIRE_DATE DATE SALARY NUMBER(10) Which UPDATE statement will accomplish your objective? UPDATE employees SET last_name = 'cooper' WHERE last_name = 'roper'.DELETE with a WHERE clause You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEES table using one UPDATE statement. One of the sales representatives. Assume all the column names are correct. Which script should you use? DELETE FROM products WHERE supplier_id IN (SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ATLANTA'). 1700). The following SQL statement will execute which of the following? INSERT INTO departments (department_id. Janet Roper. Her employee ID is still 189. has informed you that she was recently married.2) QTY_IN_STOCK NUMBER QTY_ON_ORDER NUMBER REORDER_LEVEL NUMBER You want to delete any products supplied by the five suppliers located in Atlanta. and she has requested that you update her name in the employee database. Janet is the only person with the last name of Roper that is employed by the company. 100. department_name. Her new last name is Cooper. 'Public Relations'. 70 will be inserted into the department_id column . Primary Key PRODUCT_NAME VARCHAR2 (25) SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table CATEGORY_ID NUMBER QTY_PER_UNIT NUMBER UNIT_PRICE NUMBER (7. however. Which clause should you include in the UPDATE statement to update multiple columns? The SET clause What keyword in an UPDATE statement speficies the columns you want to change? SET Examine the structures of the PRODUCTS and SUPPLIERS tables: SUPPLIERS SUPPLIER_ID NUMBER NOT NULL. One of your employees was recently married. location_id) VALUES (70.

Which script did you use? SELECT SUBSTR(product_id. -2) FROM dual. . Which element would you use? YEAR Which SELECT statement will NOT return a date value? SELECT (SYSDATE . Which function should you use? UPPER You query the database with this SQL statement: SELECT CONCAT(last_name.248. What value does this statement produce? 1300 Evaluate this function: MOD (25. Which value is returned by this command? 13 You issue this SQL statement: SELECT ROUND (1282. The ROUND number function rounds a value to a specified decimal place or the nearest whole number. Which function will be evaluated first? LOWER Which SQL function is used to return the position where a specific character string begins within a larger character string? INSTR Which three statements about functions are true? The SYSDATE function returns the Oracle Server date and time. (SUBSTR(LOWER(first_name). The SUBSTR character function returns a portion of a string beginning at a defined character position to a specified length.You need to display each employee's name in all uppercase letters. Which function should you use? LENGTH You issue this SQL statement: SELECT INSTR ('organizational sales'. The PRICE table contains this data: PRODUCT_ID MANUFACTURER_ID 86950 59604 You query the database and return the value 95.hire_date) + 10*8 FROM employees. 2) Which value is returned? 1 Which two functions can be used to manipulate number or date column values. 2) FROM price WHERE manufacturer_id = 59604. 3. You need to display the number of characters in each customer's last name. 4))) "Default Password" FROM employees. but NOT character column values? TRUNC ROUND You need to display the current year as a character value (for example: Two Thousand and One). 'al') FROM dual.

000.99') FROM product.999.900.30"? SELECT TO_CHAR(price. Which query should you issue? SELECT orderid. Evaluate this SELECT statement: SELECT SYSDATE + 30 FROM dual. '$999. YYYY') FROM employees. Use the TO_CHAR function to convert a number or date value to character string.00') FROM employees.00"? SELECT TO_CHAR(salary. You want the orders with the highest amounts to appear first. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2 (25) FIRST_NAME VARCHAR2 (25) HIRE_DATE DATE You need to display HIRE_DATE values in this format: January 28. Which function should you use? MONTHS_BETWEEN You want to create a report that displays all orders and their amounts that were placed during the month of January. Which statement concerning single row functions is true? Single row functions can be nested. Which of the following General Functions will return the first non-null expression in the expression list? COALESCE Which statement about group functions is true? .You need to display the number of months between today's date and each employee's hiredate. Which value is returned by the query? the current date plus 30 days Which three statements concerning explicit data type conversions are true? Use the TO_DATE function to convert a character string to a date value. 'Month DD. 2000 Which SELECT statement could you use? SELECT TO_CHAR(hire_date. total FROM orders WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02' ORDER BY total DESC. Use the TO_NUMBER function to convert a character string of digits to a number. Which script should you use to display the salaries in format: "$45. '$99. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2 (25) FIRST_NAME VARCHAR2 (25) SALARY NUMBER(6) You need to create a report to display the salaries of all employees. Which SQL Statement should you use to display the prices in this format: "$00. Which best describes the TO_CHAR function? The TO_CHAR function can be used to display dates and numbers according to formatting conventions that are supported by Oracle.

Which result will the query provide? STYLE_ID STYLE_NAME CATEGORY COST 968950 SANDAL 85909 10.department_id > 5000 ORDER BY 4.first_name. category.companyname.custid. e.amount FROM customers c.00 857689 HEEL 85940 11.00 890890 LOAFER 89789 14.department_id = d.employee_id. custid. Evaluate this SQL statement: SELECT e. d. and their corresponding order totals should be sorted from the highest amount to the lowest amount.department_name FROM employees e. bonus_pct FROM employees e. style_name. how many join conditions are needed in the WHERE clause? 2 You have the following EMPLOYEES table: EMPLOYEE_ID NUMBER(5) NOT NULL PRIMARY KEY FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25) ADDRESS VARCHAR2(35) CITY VARCHAR2(25) STATE VARCHAR2(2) ZIP NUMBER(9) TELEPHONE NUMBER(10) DEPARTMENT_ID NUMBER(5) NOT NULL FOREIGN KEY The BONUS table includes the following columns: BONUS_ID NUMBER(5) NOT NULL PRIMARY KEY ANNUAL_SALARY NUMBER(10) BONUS_PCT NUMBER(3.000 .department_id AND employees.00 758960 SANDAL 86979 When joining 3 tables in a SELECT statement.orderdate. orders o WHERE c. The customers should be listed alphabetically beginning with the letter 'A'.00 895840 SANDAL 85940 12. amount DESC.employee_id. b. o. e.00 968950 SANDAL 85909 10.employee_id = b. You have been asked to create a report that lists all corporate customers and all orders that they have placed.first_name. Which of the following statements should you issue? SELECT c. departments d WHERE e. cost. c.00 758960 SANDAL 86979 Evaluate this SELECT statement: SELECT style_id. Which clause contains a syntax error? AND employees.custid = o. o.00 869506 SANDAL 89690 15. The STYLES table contains this data: STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12.last_name. cost FROM styles WHERE style_name = 'SANDAL' AND NVL(cost. e. o. 2) EMPLOYEE_ID VARCHAR2(5) NOT NULL FOREIGN KEY You want to determine the amount of each employee's bonus. bonus b WHERE e. NVL2.department_id > 5000 (*) You need to create a report that lists all employees in department 10 (Sales) whose salary is not equal to $25. Which of the following queries should you issue? SELECT e.NVL.last_name.annual_salary * b. as a calculation of salary times bonus.custid ORDER BY companyname. and COALESCE can be used with group functions to replace null values. 0) < 15.00 809090 LOAFER 89098 10.00 ORDER BY category.

per year. Which query should you issue to accomplish this task? SELECT last_name, first_name, salary FROM employees WHERE salary != 25000 AND department_id = 10; What happens when you create a Cartesian product? All rows from one table are joined to all rows of another table Which statement about outer joins is true? The OR operator cannot be used to link outer join conditions. The EMPLOYEE_ID column in the EMPLOYEES table corresponds to the EMPLOYEE_ID column of the ORDERS table. The EMPLOYEE_ID column in the ORDERS table contains null values for rows that you need to display. Which type of join should you use to display the data? outer join Using Oracle Proprietary join syntax, which two operators can be used in an outer join condition using the outer join operator (+)? AND and = Which statement about a natural join is true? Columns with the same names must have the same precision and datatype. Which of the following best describes a natural join? A join between two tables that includes columns that share the same name, datatypes and lengths The following SQL statement will produce what output? SELECT last_name, department_name FROM employees CROSS JOIN departments; A Cartesian product between the two tables. For which condition would you use an equijoin query with the USING keyword? You need to perform a join of the CUSTOMER and ORDER tables but limit the number of columns in the join condition. Below find the structure of the CUSTOMERS and SALES_ORDER tables: CUSTOMERS CUSTOMER_ID NUMBER NOT NULL, Primary Key CUSTOMER_NAME VARCHAR2 (30) CONTACT_NAME VARCHAR2 (30) CONTACT_TITLE VARCHAR2 (20) ADDRESS VARCHAR2 (30) CITY VARCHAR2 (25) REGION VARCHAR2 (10) POSTAL_CODE VARCHAR2 (20) COUNTRY_ID NUMBER Foreign key to COUNTRY_ID column of the COUNTRY table PHONE VARCHAR2 (20) FAX VARCHAR2 (20) CREDIT_LIMIT NUMBER(7,2) SALES_ORDER ORDER_ID NUMBER NOT NULL, Primary Key CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table ORDER_DT DATE ORDER_AMT NUMBER (7,2) SHIP_METHOD VARCHAR2 (5)

You need to create a report that displays customers without a sales order. Which statement could you use? SELECT c.customer_name FROM customers c WHERE c.customer_id not in (SELECT s.customer_id FROM sales_order s); The primary advantage of using JOIN ON is: It permits columns with different names to be joined Evaluate this SELECT statement: SELECT a.last_name || ', ' || a.first_name as "Patient", b.last_name || ', ' || b.first_name as "Physician", c.admission FROM patient a JOIN physician b ON (b.physician_id = c.physician_id) JOIN admission c ON (a.patient_id = c.patient_id); Which clause generates an error? ON (b.physician_id = c.physician_id) What should be included in a SELECT statement to return NULL values from all tables? full outer joins Which query will retrieve all the rows in the EMPLOYEES table, even if there is no match in the DEPARTMENTS table? SELECT e.last_name, e.department_id, d.department_name FROM employees e LEFT OUTER JOIN departments d ON (e.department_id = d.department_id); Which type of join returns rows from one table that have NO direct match in the other table? outer join Evaluate this SELECT statement: SELECT MIN(hire_date), department_id FROM employees GROUP BY department_id; Which values are displayed? The earliest hire date in each department. Which statement about the GROUP BY clause is true? The first column listed in the GROUP BY clause is the most major grouping. Evaluate this SELECT statement: SELECT MAX(salary), department_id FROM employees GROUP BY department_id; Which values are displayed? The highest salary in each department. What will the following SQL Statement do? SELECT job_id, COUNT(*) FROM employees GROUP BY job_id; Displays each job id and the number of people assigned to that job id. Which group function would you use to display the lowest value in the SALES_AMOUNT column? MIN

Group functions return a value for ________________ and ________________ null values in their computations. a row set, ignore The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) SALARY NUMBER(9,2) HIRE_DATE DATE BONUS NUMBER(7,2) COMM_PCT NUMBER(4,2) Which three functions could be used with the HIRE_DATE, LAST_NAME, or SALARY columns? MAX MIN COUNT Which group function would you use to display the total of all salary values in the EMPLOYEE table? SUM You need to calculate the standard deviation for the cost of products produced in the Birmingham facility. Which group function will you use? STDDEV You need to calculate the average salary of employees in each department. Which group function will you use? AVG You need to compute the total salary for all employees in department 10. Which group function will you use? SUM Which aggregate function can be used on a column of the DATE data type? MAX Evaluate this SQL statement: SELECT COUNT (amount) FROM inventory; What will occur when the statement is issued? The statement will count the number of rows in the INVENTORY table where the AMOUNT column is not null. Which SELECT statement will calculate the number of rows in the PRODUCTS table? SELECT COUNT (*) FROM products; The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) SALARY NUMBER(7,2) DEPARTMENT_ID NUMBER(9) You need to display the number of employees whose salary is greater than $50,000? Which SELECT would you use? SELECT * FROM employees WHERE salary < 50000; SELECT COUNT(*) FROM employees WHERE salary < 50000; SELECT COUNT(*) FROM employees WHERE salary > 50000; Examine the data from the LINE_ITEM table: LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT 890898 847589 848399 8.99 0.10 768385 862459 849869 5.60 0.05 867950 985490 945809 5.60 954039 439203 438925 5.25 0.15

000. The report should include only those employees who have been with the company for more than one year and whose salary exceeds $40. dept_id FROM employee WHERE status = 'I' GROUP BY dept_id HAVING salary > 30000 ORDER BY 2. Which SQL statement did you execute? SELECT COUNT(discount) FROM line_item.543949 349302 453235 4. employee identification number. Which of the following SELECT statements will accomplish this task? . date of hire and salary. Which statement could you use to accomplish this task? SELECT prod_cat. Evaluate this SELECT statement: SELECT COUNT(emp_id). You want to write a report that returns the average salary of all employees in the company. department_name FROM employees WHERE department_id = 1 GROUP BY department. Evaluate this SELECT statement: SELECT SUM(salary). The EMPLOYEES table contains the following columns: EMPLOYEES: EMPLOYEE_ID NUMBER(10) PRIMARY KEY LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) DEPARTMENT VARCHAR2(20) HIRE_DATE DATE SALARY NUMBER(10) Which SELECT statement will return the information that you require? SELECT AVG (salary) FROM employees GROUP BY department. department_id. sorted by departments.50 You query the LINE_ITEM table and a value of 3 is returned. Why does this statement return a syntax error? MGR_ID must be included in the GROUP BY clause. The PRODUCTS table contains these columns: PROD_ID NUMBER(4) PROD_NAME VARCHAR(20) PROD_CAT VARCHAR2(15) PROD_PRICE NUMBER(5) PROD_QTY NUMBER(4) You need to identify the minimum product price in each product category. MIN (prod_price) FROM products GROUP BY prod_cat. Which clause of the SELECT statement contains a syntax error? GROUP BY The EMPLOYEES table contains the following columns: EMPLOYEE_ID NUMBER(10) PRIMARY KEY LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) DEPARTMENT VARCHAR2(20) HIRE_DATE DATE SALARY NUMBER(10) You want to create a report that includes each employee's last name. mgr_id.

you should use a WHERE clause.team_id) WHERE UPPER(p. Using a subquery in which of the following clauses will return a syntax error? You can use subqueries in all of the above clauses. Which SQL statement will display the desired result? SELECT category_id.00. Which SELECT statement will produce the desired result? SELECT t.player_id) FROM players p JOIN teams t ON (p.00 GROUP BY category_id. The extended cost of each item equals the quantity value multiplied by the cost value. Which statement about the GROUP BY clause is true? To exclude rows before dividing them into groups using the GROUP BY clause.team_name HAVING COUNT(p. location_id.2) PRICE NUMBER(7.2) QUANTITY NUMBER You display the total of the extended costs for each product category by location. The PLAYERS and TEAMS tables contain these columns: PLAYERS PLAYER_ID NUMBER NOT NULL.team_name. hire_date. . You need to include only the products that have a price less than $25.SELECT employee_id. COUNT(p. total FROM ORDERS WHERE employee_id = (SELECT employee_id FROM employees WHERE last_name = 'Franklin') AND order_date BETWEEN '01-jan-01' AND '31-dec-01'.team_id = t.player_id) > 3. SUM(cost * quantity) TOTAL. location_id FROM products WHERE price < 25. salary FROM employees WHERE salary > 40000 AND (sysdate-hire_date) / 365 > 1. last_name. Primary Key LAST_NAME VARCHAR2 (30) NOT NULL FIRST_NAME VARCHAR2 (25) NOT NULL TEAM_ID NUMBER POSITION VARCHAR2 (25) TEAMS TEAM_ID NUMBER NOT NULL.position) = 'GOAL KEEPER' GROUP BY t. The PRODUCTS table contains these columns: PRODUCT_ID NUMBER(9) PK CATEGORY_ID VARCHAR2(10) LOCATION_ID NUMBER(9) DESCRIPTION VARCHAR2(30) COST NUMBER(7. Primary Key TEAM_NAME VARCHAR2 (25) You need to create a report that lists the names of each team with more than three goal keepers. The EMPLOYEES and ORDERS tables contain these columns: EMPLOYEES EMPLOYEE_ID NUMBER(10) NOT NULL PRIMARY KEY FIRST_NAME VARCHAR2(30) LAST_NAME VARCHAR2(30) ADDRESS VARCHAR2(25) CITY VARCHAR2(20) STATE VARCHAR2(2) ZIP NUMBER(9) TELEPHONE NUMBER(10) ORDERS ORDER_ID NUMBER(10) NOT NULL PRIMARY KEY EMPLOYEE_ID NUMBER(10) NOT NULL FOREIGN KEY ORDER_DATE DATE TOTAL NUMBER(10) Which SELECT statement will return all orders generated by a sales representative named Franklin during the year 2001? SELECT order_id.

Which query should you issue to accomplish this task? SELECT * FROM employees WHERE supervisor_id = (SELECT employee_id FROM employees WHERE last_name = 'Carter'). and ORDERS tables. However. DEPARTMENT. Which best describes a single-row subquery? a query that returns only one row from the inner SELECT statement Which best describes a multiple-row subquery? A query that returns one or more rows from the inner SELECT statement What is wrong with the following query? SELECT employee_id. last_name FROM employees WHERE salary = (SELECT MIN(salary) FROM employees GROUP BY department_id). Which of the following constructs would you use? a single-row subquery Examine the following EMPLOYEES table: EMPLOYEES EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) DEPARTMENT_ID NUMBER(9) SUPERVISOR_ID NUMBER(9) You need to produce a report that contains all employee-related information for those employees who have Brad Carter as a supervisor. Which operator can be used with subqueries that return only one row? LIKE Examine the structure of the EMPLOYEE. . you are not sure which supervisor ID belongs to Brad Carter.Which of the following is TRUE regarding the order of subquery execution? The subquery executes once before the main query Which statement about subqueries is true? Subqueries are often used in a WHERE clause to return values for an unknown conditional value. EMPLOYEE EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) DEPARTMENT_ID NUMBER(9) DEPARTMENT DEPARTMENT_ID NUMBER(9) DEPARTMENT_NAME VARCHAR2(25) CREATION_DATE DATE ORDERS ORDER_ID NUMBER(9) EMPLOYEE_ID NUMBER(9) DATE DATE CUSTOMER_ID NUMBER(9) You want to display all employees who had an order after the Sales department was established.

2) DEPART_HIST: EMPLOYEE_ID NUMBER(9) OLD_DEPT_ID NUMBER(9) NEW_DEPT_ID NUMBER(9) CHANGE_DATE DATE .00).Subquery returns more than one row and single row comparison operator is used. Evaluate this SELECT statement: SELECT student_id. but less than $50. Which values will be displayed? All employees who work in a department with employees who earn more than $30.000. Which operator or keyword cannot be used with a multiple-row subquery? = You need to display all the products that cost more than the maximum cost of every product produced in Japan. Evaluate this SELECT statement: SELECT customer_id. first_name FROM student WHERE major_id NOT IN (SELECT major_id FROM majors WHERE department_head_id = 30 AND title = 'ADJUNCT'). Evaluate this SQL statement: SELECT employee_id. What would happen if the inner query returned a NULL value row? No rows would be returned from the STUDENT table. Which of the following statements contains a comparison operator that is used to restrict rows based on a list of values returned from an inner query? All of the above. salary FROM employees WHERE department_id IN (SELECT department_id FROM employees WHERE salary > 30000 AND salary < 50000). last_name. last_name. name FROM customer WHERE customer_id IN (SELECT customer_id FROM customer WHERE state_id = 'GA' AND credit_limit > 500. What would happen if the inner query returned null? No rows would be returned by the outer query. Which multiple-row comparison operator could you use? >ANY Evaluate the structure of the EMPLOYEE and DEPART_HIST tables: EMPLOYEE: EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) DEPARTMENT_ID NUMBER(9) MANAGER_ID NUMBER(9) SALARY NUMBER(7.000. A multiple-row operator expects how many values? One or more What would happen if you attempted to use a single-row operator with a multiple-row subquery? An error would be returned.

new_dept_id FROM depart_hist WHERE old_dept_id = 15) AND new_dept_id = 10. 'tflanders'.04. . 'tflanders'. first_name. you should not add an amount to the CREDIT column. 8690. The PRODUCTS table contains these columns: PROD_ID NUMBER(4) PROD_NAME VARCHAR2(25) PROD_PRICE NUMBER(3) You want to add the following row data to the PRODUCTS table: (1) a NULL value in the PROD_ID column (2) "6-foot nylon leash" in the PROD_NAME column (3) "10" in the PROD_PRICE column You issue this statement: INSERT INTO products VALUES (null. 'InterCargo'. 'InterCargo'. 7.You want to generate a list of employees who are in department 10. 'samerica').'6-foot nylon leash'. The CUSTOMERS table contains these columns: CUST_ID NUMBER(10) COMPANY VARCHAR2(30) CREDIT NUMBER(10) POC VARCHAR2(30) LOCATION VARCHAR2(30) Which two INSERT statements will accomplish your objective? INSERT INTO customers (cust_id. location) VALUES (200. 'samerica'). Evaluate this partial UPDATE statement: UPDATE employee SET area_code = 770 Which of the following should you include in your UPDATE statement to achieve the desired results? WHERE city = 'Atlanta'. INSERT INTO customers VALUES (200. Which query should you use? SELECT employee_id. 'Cable'.2) QTY_IN_STOCK NUMBER(4) LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE Which INSERT statement will execute successfully? INSERT INTO products VALUES (2958. Which statement about the VALUES clause of an INSERT statement is true? If no column list is specified. What row data did you add to the table? The row was created with the correct data in all three columns.2) COST NUMBER (5. last_name. then the values must be in the order the columns are specified in the table. Because the new customer has not had a credit check. but used to be in department 15. company. You have been instructed to add a new customer to the CUSTOMERS table. 700).09. 10). poc. department_id FROM employee WHERE (employee_id. The PRODUCTS table contains these columns: PRODUCT_ID NUMBER NOT NULL PRODUCT_NAME VARCHAR2 (25) SUPPLIER_ID NUMBER NOT NULL LIST_PRICE NUMBER (7. 4. null. You need to update the area code of employees that live in Atlanta . department_id) IN (SELECT employee_id.

2) You want to execute one DML statement to change the salary of all employees in department 10 to equal the new salary of employee id 89898. You want to enter a new record into the CUSTOMERS table. '37777'). 'TN'. Which two commands can be used to modify existing data in a database row? MERGE UPDATE When the WHERE clause is missing in a DELETE statement. Which of the following represents the correct syntax for an INSERT statement? INSERT INTO customers VALUES (3178. 'J. '123 Main Street'. all employees in department 10 have the same salary value. and TEAMS tables: PLAYERS PLAYER_ID NUMBER Primary Key LAST_NAME VARCHAR2 (30) FIRST_NAME VARCHAR2 (25) TEAM_ID NUMBER MGR_ID NUMBER SIGNING_BONUS NUMBER(9. You need to delete a record in the EMPLOYEES table for Tim Jones.2) SALARY NUMBER(9. Which statement should you execute? UPDATE employees SET salary = (SELECT salary FROM employees WHERE employee_id = 89898) WHERE department_id = 10.'.2) BONUS NUMBER(9. Currently. MERGE Examine the structures of the PLAYERS. 'Nashville'. MANAGERS. what is the result? All rows are deleted from the table. whose unique employee identification number is 348. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(5) PRIMARY KEY LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) ADDRESS VARCHAR2(30) PHONE NUMBER(10) Which DELETE statement will delete the appropriate record without deleting any additional records? DELETE FROM employees WHERE employee_id = 348. Which two commands can be used to create new rows? INSERT.What would happen if you issued a DELETE statement without a WHERE clause? All the rows in the table would be deleted. The EMPLOYEES table contains the following columns: EMPLOYEE_ID NUMBER(10) PRIMARY KEY LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) DEPARTMENT_ID NUMBER(10) HIRE_DATE DATE SALARY NUMBER(9. 'Smith'.2) MANAGERS MANAGER_ID NUMBER Primary Key LAST_NAME VARCHAR2 (20) FIRST_NAME VARCHAR2 (20) TEAM_ID NUMBER .

TEAMS TEAM_ID NUMBER Primary Key TEAM_NAME VARCHAR2 (20) OWNER_LAST_NAME VARCHAR2 (20) OWNER_FIRST_NAME VARCHAR2 (20) Which situation would require a subquery to return the desired result? To display the names of the managers for all the teams owned by a given owner Evaluate this statement: DELETE FROM customer. Which statement is true? The statement deletes all the rows from the CUSTOMER table. .

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.