s2m

20

Click here to load reader

Upload: nicolae-stan

Post on 20-Jul-2016

255 views

Category:

Documents


15 download

TRANSCRIPT

Page 1: s2m

1. In the following example, where do you place the phrase BULK COLLECT?

DECLARE    TYPE NameList IS TABLE OF emp.ename%TYPE;    names NameList;    CURSOR c1 IS SELECT ename -- Position A    FROM emp WHERE job = 'CLERK'; BEGIN    OPEN c1;    FETCH c1 -- Position B INTO -- Position C names;    ...    CLOSE c1; END; 

 Mark for Review 

(1) Points

Position APosition B (*)Position C

Correct

2.  In the following example, where do you place the phrase DETERMINISTIC?

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

 Mark for Review 

(1) Points

Position APosition B (*)Position C

Correct

Page 2: s2m

3.  In the following example, where do you place the phrase BULK COLLECT?

... BEGIN   SELECT -- Position A      salary -- Position B      INTO v_saltab -- Position C      FROM employees WHERE department_id = 20 ORDER BY salary      -- Position D ; ... 

 Mark for Review 

(1) Points

Position APosition B (*)Position CPosition D

Correct

4. What are benefits of using the NOCOPY hint? (Choose two)  Mark for Review 

(1) Points

(Choose all correct answers)

Safer because it uses passing by value.Efficient since it uses less memory. (*)Uses a larger block of server memory for faster access.Faster because a single copy of the data is used. (*)

Correct

5. Name two reasons for using Dynamic SQL.  Mark for Review 

(1) Points

(Choose all correct answers)

Avoid errrors at compile time of DML statements.Create a SQL statement with varying column data, or different conditions. (*)Enables data-definition statements to be written and executed from PL/SQL. (*)Enables system control statements to be written and executed from PL/SQL.

Page 3: s2m

Correct

6. Only one call to DBMS_SQL is needed in order to drop a table. True or False?  Mark for

Review (1) Points

TrueFalse (*)

Correct

7. For which of the following is it necessary to use Dynamic SQL? (Choose three.)  Mark for

Review (1) Points

(Choose all correct answers)

ALTER (*)GRANT (*)SAVEPOINTUPDATEDROP (*)

Correct

8. A programmer wants to code a procedure which will create a table with a single column. The datatype of the column will be chosen by the user who invokes the procedure. The programmer writes the following code:

CREATE OR REPLACE PROCEDURE create_tab     (p_col_datatype IN VARCHAR2) IS BEGIN     CREATE TABLE newtab (only_col p_col_datatype); END;

Why will this procedure not compile successfully?

 Mark for Review 

(1) Points

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

Page 4: s2m

Correct

Section 10(Answer all questions in this section)

9. Which of the following best describes a package initialization block?  Mark for

Review (1) Points

It is a named procedure in a package which must be invoked by a user before any other part of the package can be invoked.It is an anonymous block in the package specification.It is an anonymous block at the end of a package body which executes automatically the first time each user session invokes a subprogram in the package. (*)It is a private function within the package body.Because it is an anonymous block, it cannot be invoked and therefore will never execute. It is treated as a set of comments.

Correct

10. A package initialization block is executed automatically every time a user invokes any procedure or function in the package. True or False?

 Mark for Review 

(1) Points

TrueFalse (*)

Correct

Page 1 of 5 Next Summary11. When

using a package function in DML statements, which rules must you follow? (Choose three)

 Mark for Review 

(1) Points

(Choose all correct answers)

Page 5: s2m

Must not end the current transaction (*)Can read or modify the table being changed by that DML statementChanges to a package variable could have an impact on another stored function (*)Cannot execute a DML statement or modify the database (*)

Correct

12.  INDEX BY is missing from this package declaration. What is the most efficient declaration?

CREATE OR REPLACE PACKAGE emp_pkg IS    TYPE emp_tab IS TABLE OF employees%ROWTYPE;    PROCEDURE get_employees(p_emp_table OUT emp_tab); END emp_pkg;

 Mark for Review 

(1) Points

INDEX BY INTEGERINDEX BY BINARYINDEX BY BINARY_INTEGER (*)INDEX ALL

Correct

13. The package name must be included when calling a package function from a SELECT statement executed outside the package. True or False?

 Mark for Review 

(1) Points

True (*)False

Correct

14. Which of the following can be included in a package? Mark for Review 

(1) Points

proceduresvariablesPL/SQL typesExceptionsAll of the above (*)

Correct

Page 6: s2m

15. A number variable declared in a package is initialized to 0 unless assigned another value. True or False?  Mark for

Review (1) Points

TrueFalse (*)

Correct

16. Package Specification DEPT_PACK was created by the following code:

CREATE OR REPLACE PACKAGE dept_pack IS     PROCEDURE ins_dept(p_deptno IN NUMBER);     FUNCTION get_dept(p_deptno IN NUMBER) RETURN VARCHAR2;END dept_pack;

Which of the following are correct syntax for invoking the package subprograms? (Choose two.)

 Mark for Review 

(1) Points

(Choose all correct answers)

BEGIN     dept_pack.ins_dept(20);END;

(*)BEGIN     dept_pack.get_dept(20);END;DECLARE     v_deptname VARCHAR2(20);BEGIN    v_deptname := get_dept(50);END;CREATE PROCEDURE dept_proc IS    v_deptname VARCHAR2(20);BEGIN    v_deptname := dept_pack.get_dept(40);END;

(*)BEGIN     dept_pack(30);END;

Correct

17. Which of the following are good reasons to group a set of procedures and functions into a package?  Mark for

Review (1) Points

Page 7: s2m

Application developers do not need to know the details of the package body code.Related subprograms and variables can be grouped together for easier management and maintenance.If the detailed code is changed, aplications which invoke the package do not need to be recompiled.All of the above. (*)

Correct

18. A local variable defined inside a package procedure is visible to the calling environment. True or False?  Mark for

Review (1) Points

TrueFalse (*)

Correct

19. A local variable declared within a procedure in a package can be referenced by any other component of that package. True or False?  Mark for

Review (1) Points

TrueFalse (*)

Correct

20. Examine the following package specification:

CREATE OR REPLACE PACKAGE mypack IS     percent_tax NUMBER := 20;     PROCEDURE proc1; END mypack;

The package body of mypack also includes a function called func1. Which of the following statements are true? (Choose three.)

 Mark for Review 

(1) Points

(Choose all correct answers)

proc1 is a public procedure and func1 is a private function.

(*)The package will not compile because you cannot declare variables in the specification, only procedures and functions. .The variable can be modified by:

BEGIN 

Page 8: s2m

    mypack.percent_tax := 10; END;

(*)The function can be invoked from outside the package.The procedure can be invoked by:

BEGIN     mypack.proc1; END;

(*)

Correct

Previous Page 2 of 5Next Summary

Section 10(Answer all questions in this section)

21. A public component declared in the package specification can be referenced by a private component defined in the package body. True or False?

 Mark for Review 

(1) Points

True (*)False

Correct

22. Your schema contains a package called EMP_PKG. You want to remove the package body but not the specification. The correct syntax to do this is: DROP BODY emp_pkg; True or False?

 Mark for Review 

(1) Points

TrueFalse (*)

Correct

Section 13(Answer all questions in this section)

Page 9: s2m

23. What are the timing events for a compound trigger?  Mark for Review 

(1) Points

Before the triggering statement; After the triggering statement; Instead of the triggering statement.Before the triggering statement; Before each row; After each row; After the triggering statement. (*)Before the triggering statement; After the triggering statement; After each row.Before the triggering statement; Before each row; After the triggering statement.

Correct

24. You decide to create the following trigger:

CREATE OR REPLACE TRIGGER empl_trigg BEFORE UPDATE ON employees BEGIN        -- Line A        RAISE_APPLICATION_ERROR('Cannot update salary');     ELSE        INSERT INTO log_table values (USER, SYSDATE);     END IF; END;

You want the trigger to prevent updates to the SALARY column, but allow updates to all other columns. What should you code at Line A?

 Mark for Review 

(1) Points

IF UPDATING SALARY THENIF UPDATING('SALARY') THEN (*)IF UPDATE('SALARY') THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THEN

Correct

25. A row trigger has been created which is fired by UPDATE ON employees. A user now executes a single SQL statement which updates four rows of the EMPLOYEES table. How many times will the row trigger fire?

 Mark for Review 

(1) Points

OnceTwiceFour times (*)Five timesEight times

Page 10: s2m

Correct

26. The OLD and NEW qualifiers can be used with statement triggers as well as row triggers. True or False?  Mark for

Review (1) Points

TrueFalse (*)

Correct

27. Which of the following best describes conditional predicates in a trigger?  Mark for Review 

(1) Points

They are special variables which must be DECLAREd within the trigger.They allow the trigger code to see what data values are being inserted into a row.They are automatically declared boolean variables which allow the trigger body to detect which DML operation is being executed. (*)They are special cursor attributes, like %ROWCOUNT and %NOTFOUND

Correct

28. You have created several DML triggers which reference your DEPARTMENTS table. Now you want to disable all of them using a single SQL statement. Which command should you use?

 Mark for Review 

(1) Points

ALTER TRIGGER DISABLE ALL ON departments;ALTER TABLE departments DISABLE ALL TRIGGERS; (*)ALTER TABLE departments DISABLE TRIGGERS;DROP ALL TRIGGERS ON departments;

Correct

29. Which dictionary view would you query to see the detailed body code of triggers in your schema?  Mark for

Review (1) Points

USER_SOURCEUSER_TRIGGERUSER_TRIGGERS (*)USER_OBJECTS

Page 11: s2m

None of the above, you cannot view the code of the trigger body after the trigger has been created.

Correct

30. A user creates the following trigger:

CREATE OR REPLACE TRIGGER emp_trigg AFTER DELETE ON employees BEGIN     ... END;

The user now tries to drop the EMPLOYEES table. What happens?

 Mark for Review 

(1) Points

The table is dropped but the trigger is not dropped.An error message is displayed because you cannot drop a table that is referenced by a trigger.The table is dropped and the trigger is disabled.Both the table and the trigger are dropped. (*)

Correct

Previous Page 3 of 5 Next Summary

Section 13(Answer all questions in this section)

31. What is wrong with the following code?

CREATE OR REPLACE TRIGGER mytrigg AFTER DELETE ON departments BEGIN     INSERT INTO audit_table (who, when)        VALUES (USER, SYSDATE);     COMMIT; END; 

 Mark for Review 

(1) Points

A DML trigger cannot itself contain a DML statement such as INSERT INTO audit_tableYou cannot use COMMIT inside a trigger. (*)The last line of code should be END mytrigg;The second line should be: AFTER DELETE OF DEPARTMENTSNothing is wrong, the trigger will execute successfully

Correct

32. We want to create a log record automatically every time any DML operation is executed on either or both of the EMPLOYEES and DEPARTMENTS tables. What is the smallest number of

 Mark for

Page 12: s2m

triggers that must be create to do this? Review (1) Points

OneTwo (*)ThreeSixEight

Correct

33. Which of the following are possible keywords for the timing component of a trigger? (Choose three.)  Mark for

Review (1) Points

(Choose all correct answers)

BEFORE (*)INSTEADWHENEVERINSTEAD OF (*)AFTER (*)

Correct

34. Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table? The trigger must fire whenever an employee's JOB_ID is updated, but not if a different column is updated.

 Mark for Review 

(1) Points

CREATE TRIGGER job_upd_trigg AFTER UPDATE ON employees(job_id)BEGIN ...CREATE TRIGGER job_upd_trigg WHENEVER UPDATE OF job_id IN employees BEGIN ...CREATE TRIGGER job_upd_trigg AFTER UPDATE ON employees.job_idBEGIN ...CREATE TRIGGER job_upd_trigg AFTER UPDATE OF job_id ON employeesBEGIN ...

(*)

Correct

Page 13: s2m

35. You have been granted CREATE TRIGGER privilege. You can now create an AFTER LOGOFF ON SCHEMA trigger. True or False?  Mark for

Review (1) Points

TrueFalse (*)

Correct

36. You can create a trigger which prevents DDL statements on an individual table, while still allowing DDL on other tables in the same schema. True or False?

 Mark for Review 

(1) Points

TrueFalse (*)

Correct

37. What is wrong with the following code?

CREATE OR REPLACE TRIGGER emp_dml_trigg BEFORE UPDATE OF salary ON employees FOR EACH ROW DECLARE     v_max_sal employees.salary%TYPE; BEGIN     SELECT max(sal) INTO v_max_sal FROM employees; END; 

 Mark for Review 

(1) Points

You cannot use a DECLARE statement in a trigger.The trigger body is reading the same table (employees) that the triggering event is updating. (*)You must use RAISE_APPLICATION_ERROR in a BEFORE trigger.You can never use SELECT inside a DML trigger.Nothing is wrong, the trigger will execute correctly.

Correct

38. The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database. What type of trigger is this?

 Mark for Review 

(1) Points

A DDL triggerA Database Event trigger (*)A DML trigger

Page 14: s2m

A statement triggerAn INSTEAD OF trigger

Correct

39. Which of the following are NOT allowed within a database trigger? (Choose two)  Mark for

Review (1) Points

(Choose all correct answers)

COMMIT (*)A call to a packaged procedureINSERTA Boolean variableSAVEPOINT (*)

Correct

40. Which of the following could NOT be done by a database trigger?  Mark for Review 

(1) Points

Enforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employee's salary is changedEnsuring that a student never arrives late for a class (*)Keeping a log of how many rows have been inserted into a table

Correct

Previous Page 4 of 5 Next SummarySection 13

(Answer all questions in this section)

41. While editing a document in Microsoft Word, you go to the FILE menu and SAVE your work. To do this, Microsoft Word has executed an application trigger. True or False?

 Mark for Review 

(1) Points

True (*)

Page 15: s2m

False

Correct

42. Which of the following best describes a database trigger? Mark for Review 

(1) Points

It allows users to log on to the databaseIt executes automatically whenever a particular event occurs within the database (*)It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with their mouseIt allows foreign key constraints to be violated

Correct

43. Which of the following are good guidelines to follow when creating triggers? (Choose two)  Mark for

Review (1) Points

(Choose all correct answers)

Be aware of recursive and cascading effects (*)Where possible, use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it from within the trigger (*)Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need, because it is better to be safe

Correct

44. A database trigger is a PL/SQL stored subprogram which is explicitly invoked just like a procedure or a function. True or False?  Mark for

Review (1) Points

TrueFalse (*)

Correct

Page 16: s2m

Section 11(Answer all questions in this section)

45. Users A and B call the same procedure in a package to initialize a global variable my_pkg.g_var. What will be the value of my_pkg.g_var for User A at Point A?

User A: my_pkg.g_var is 10User B: my_pkg.g_var is 10User A: my_pkg.g_var is 50User B: my_pkg.g_var is 25Point A

 Mark for Review 

(1) Points

1050 (*)25

Correct

46. A package's state is initialized when the package is first loaded. True or False?  Mark for

Review (1) Points

True (*)False

Correct

47. Which DBMS_OUTPUT package subprogram places text into the buffer at Line 1? (Choose one)

IF v_bool1 AND NOT v_bool2 AND v_number < 25 THEN    --Line 1    ELSE        ... END IF; DBMS_OUTPUT.NEW_LINE;

 Mark for Review 

(1) Points

DBMS_OUTPUT.PUT('IF branch was executed'); (*)DBMS_OUTPUT.PUT_LINE('IF branch was executed');DBMS_OUTPUT.GET_LINE('IF branch was executed');DBMS_OUTPUT.NEW_LINE('IF branch was executed');

Correct

48. Using the FOPEN function, you can do which actions with the UTL_FILE package? (Choose 2)  Mark for

Review 

Page 17: s2m

(1) Points

(Choose all correct answers)

It is used to append to a file until processing is complete. (*)It is used to read and write text files stored outside the database. (*)It is used to find out how much free space is left on an operating system disk.It is used to manipulate large object data type items in columns.

Incorrect. Refer to Section 11 Lesson 2.

49. The UTL_FILE package can be used to read and write binary files such as JPEGs as well as text files. True or False?  Mark for

Review (1) Points

TrueFalse (*)

Correct

50. The UTL_FILE package contains several exceptions exclusively used in this package. Which are they? (Choose 3)  Mark for

Review (1) Points

(Choose all correct answers)

INVALID_PATH (*)NO_DATA_FOUNDWRITE_ERROR (*)INVALID_OPERATION (*)ZERO_DIVIDE

Correct

Previous Page 5 of 5 Summary