Friday, August 12, 2011

PL/SQL IQA 2


1.   The number of cascading triggers is limited by which data base initialization parameter?
  1. CASCADE_TRIGGER_CNT
  2. OPEN_CURSORS
  3. OPEN_TRIGGERS
  4. OPEN_DB_TRIGGERS 
2.   Which type of package construct must be declared both within package specifications and package body?
a.     All package variables.
b.    Boolean variables.
c.     Private procedures and functions.
d.    Public procedures and functions.

3.   Why do stored procedures and functions improve performance? (choose two)
a.   They reduce network round trips.
b.   They postpone PL/SQL parsing until run time.
c.   They allow the application to perform high speed processing locally.
d.   They reduce the number of calls to the database and decrease network traffic by bundling commands.
e.   They reduce the number of calls to the database and decrease network traffic by using the local PL/SQL engine.

4.   When creating stored procedures and functions, which construct allows you to transfer values to and from the calling environment?
  1. Local variables.
  2. Formal arguments.
  3. Boolean variables.
  4. Substitution variables.
5.   You need to remove the database trigger, BUSINESS_RULE. Which command do you use to remove the trigger in the SQL*Plus environment?
a.     DROP TRIGGER business_rule;
b.    DELETE TRIGGER business_rule;
c.     REMOVE TRIGGER business_rule;
d.    ALTER TRIGGER business_rule;
e.     DELETE FROM USER_TRIGGER WHERE TRIGGER_NAME= ‘BUSINESS_RULE’;

6.   Which two tables are fused track object dependencies?
  1. USER_DEPENDENSIES.
  2. USER_IDEPTREE.
  3. IDEPTREE.
  4. USER_DEPTREE.
  5. USER_DEPENDS.
7. The QUERY_PRODUCT procedure directly references the product table. There is a NEW_PRODUCT_VIEW view created based on the NOT NULL columns of the table. The ADD_PRODUCT procedure updates the table indirectly by the way of NEW_PRODUCT_VIEW view. Under which circumstances does the procedureADD_PRODUCT get invalidated but automatically get complied when invoked?
  1. When the NEW_PRODUCT_VIEW is dropped.
  2. When rows of the product table are updated through SQL Plus.
  3. When the internal logic of the QUERY_PRODUCT procedure is modified.
  4. When a new column that can contain null values is added to the product table.
  5. When a new procedure is created that updates rows in the product table directly.

8.   You need to recompile several program units you have recently modified through a PL/SQL program. Which statement is true?
  1. You cannot recompile program units using a PL/SQL program.
  2. You can use the DBMS_DDL. REOMPILE package procedure to recompile the program units.
  3. You can use the DBMS_ALTER. COMPILE packaged procedure to recompile the program units.
  4. You can use the DBMS_DDL.ALTER_COMPILE packaged procedure to recompile the program units.
  5. You can use the DBMS_SQL.ALTER_COMPILE packaged procedure to recompile the program units.

9.   Which type of argument passes a value from a calling environment?
  1. VARCHER2
  2. BOOLEAN
  3. OUT
  4. IN

10.  You need to create a trigger on the EMP table that monitors every row that is changed and places this information into the AUDIT_TABLE. Which type of trigger do you create?
  1. Statement-level trigger on the EMP table.
  2. For each row trigger on the EMP table. 
  3. Statement-level trigger on the AUDIT_TABLE table.
  4. For each row statement level trigger on the EMP table.
  5. For each row trigger on the AUDIT_TABLE table.

11.  In order for you to create a run package, MAINTAIN_DATA, which privilege do you need?
  1. EXECUTE privilege on the MAINTAIN_DATA package.
  2. INVOKE privilege on the MAINTAIN_DATA package.
  3. EXECUTE privilege on the program units in the MAINTAIN_DATA package.
  4. Object privilege on all of the objects that the MAINTAIN_DATA package is accessing.
  5. Execute privilege on the program units inside the MAINTAIN_DATA package and execute privilege on the MAINTAIN_DATA package.

12.  You have created a script file EMP_PROC.SQL that holds text to create a procedure, PROCESS_EMP. You have compiled the procedure for the SQL Plus environment by running the script file EMP_PROC.SQL. What happens if there are syntax errors in the procedure PROCESS_EMP?
  1. The errors are stored in the EMP_PROC.ERR file.
  2. The errors are displayed to the screen when the script file is run.
  3. The errors are stored in the PROCEDURE_ERRORS data dictionary view.
  4. You need to issue the SHOWERRORS command in the SQL Plus environment to see the errors.
  5. You need to issue the DISPLAY ERRORS command in the SQL Plus environment to see the errors.

13.  Which statement about local dependent objects is true?
  1. They are on different nodes.
  2. They are in a different database.
  3. They are on the same node in the same database.
  4. They are on the same node in a different database.

14.  You need to create a stored procedure that deletes rows from a table.  The name of the table from which the rows are to be deleted is unknown until run time.  Which method do you implement while creating such a procedure?
  1. Use SQL command DELETE in the procedure to delete the rows.
  2. Use DBMS_SQL packaged routines in the procedure to delete the rows.
  3. Use DBMS_DML packaged routines in the procedure to delete the rows.
  4. Use DBMSDELETE packaged routines in the procedure to delete the rows.
  5. YOU cannot have a delete statement without providing a table name before compile time.

15.  Under which situation do you create a server-side procedure?
  1. When the procedure contains no SQL statements.
  2. When the procedure contains no PL/SQL commands.
  3. When the procedure needs to be used by many client applications accessing several remote databases.
  4. When the procedure needs to be used by many users accessing the same schema objects on a local database.

16.  Examine this procedure:
      CREATE OR REPLACE PROCEDURE ADD_PLAYER
      (V_ID IN NUMBER, V_LAST_NAME VARCHER2)
      IS
                  BEGIN
                  INSERT INTO PLAYER(ID,LAST_NAME).
                  VALUES(V_ID,V_LAST_NAME);
                  COMMIT;
      END;
      This procedure must invoke the UPD-STAT procedure and pass a parameter. Which statement will successfully invoke this procedure?

  1. EXECUTE UPD_BAT_STAT(V_ID);
  2. UPD_BAT_STAT(V_ID);
  3. RUN UPD_BAT_STAT(V_ID);
  4. START UPD_BAT_STAT(V_ID);

17.  Match the purity levels to their correct definitions:
            Terms
            RNTS
            RNPS
            WNDS
            WNPS
            Definitions
            The function cannot modify the database tables.
            The function cannot change the values of the package variables.
            The function cannot query database tables.
            The function cannot reference the value of public packaged variables.

18.  Examine this function:
CREATE OR REPLACE FUNCTION CALC_PLAYER_AVG
(V_ID in PLAYER_BAT_STAT. PLAYER_ID%TYPE)
RETURN NUMBER
IS
V_AVG NUMBER;
SELECTS HITS/AT_BATS
INTO V_AVG
FROM PLAYER_BAT_STAT
WHERE PLAYER_ID_V_ID;
RETURN(V_AVG);
END;
      This function must be moved to a package. Which additional statement must be added to the function to allow you to continue using the function in the GROUP BY clause of a SELECT statement?
  1. PRAGMA RESTRICT_REFERENCES (CALC_PLAYER_AVG, WNDS, WNPS);
  2. PRAGMA RESTRICT_REFERENCES (CALC_PLAYER_AVG, WNPS);
  3. PRAGMA RESTRICT_REFERENCES (CALC_PLAYER_AVG, RNPS, WNPS);
  4. PRAGMA RESTRICT_REFERENCES (CALC_PLAYER_AVG, ALLOW_GROUP_BY);

19.  A programmer develops a procedure, ACCOUNT_TRANSACTION, and has left your company.  You are assigned a task to modify this procedure.  You want to find all the program units invoking the ACCOUNT_TRANSACTION procedure.  How can you find this information?
  1. Query the USER_SOURCE data dictionary view.
  2. Query the USER_PROCEDURES data dictionary view.
  3. Query the USER_DEPENDENCIES data dictionary views.
  4. Set the SQL Plus environment variable trade code=true and run the ACCOUNT_TRANSACTION procedure. 
  5. Set the SQL Plus environment variable DEPENDENCIES=TRUE and run the Account_Transaction procedure.

20.  Examine this package.
CREATE OR REPLACE PACKAGE BB_PACK
IS
V_MAX_TEAM_SALARY     NUMBER(12,2);
PROCEDURE ADD_PLAYER(V_ID NUMBER,V_LAST_NAME
VARCHER2,V_SALARY NUMBER);
END BB_PACK;
/
CREATE OR REPLACE PACKAGE BODY BB_PACK
IS
PROCEDURE UPD_PLAYER_STAT
(V_ID IN NUMBER,V_AB_IN NUMBER DEFAULT4,V_HITS IN NUMBER)
IS
BEGIN
            UPDATE PLAYER_BAT_STAT
            SET AT_BATS+V_AB,
            HITS=HITS+V_HITS
            WHERE PLAYER_ID=V_ID;
            COMMIT;
            END UPD_PLAYER_STAT;
            PROCEDURE ADD_PLAYER
(V_ID IN NUMBER,V_LAST_NAME VARCHER2,V_SALARY NUMBER)
IS
BEGIN
INSERT INTO PLAYER(ID,LAST_NAME,SALARY);
UPD_PLAYER_STAT(V_ID,0,0);
END ADD PLAYER;
END BB_PACK;
      Which statement successfully assigns $75000000 to the V_MAX_TEAM_SALARY variable from within a stand alone procedure?
  1. V_MAX_TEAM_SALARY := 75000000;
  2. BB_PACK.ADD_PLAYER. V_MAX_TEAM_SALARY := 75000000;
  3. BB_PACK.V_MAX_TEAM_SALARY := 75000000;
  4. This variable cannot be assigned a value from outside the package.

21.  Which two statements about the overloading feature of packages are true?
  1. Only local or packaged sub programs can be overloaded.
  2. Overloading allows different functions with the same name that differ only in their return types.
  3. Overloading allows different subprograms with the same number, type and order of the parameter.
  4. Overloading allows different subprograms with the same name and same number or type of the parameters.
  5. Overloading allows different subprograms with the same name but different in either number or type or order of parameters.

22.  Examine this package:
CREATE OR REPLACE manag emps
IS
Tax_rate CONSTANT NUMBER(5,2):= . 28:,
V_id NUMBER;
PROCEDURE insert_emp(p-deptno NUMBER,p-sal NUMBER);
PROCEDURE delete_emp;
PROCEDURE update_emp:
FUNCTION calc_tax(o_sal NUMBER)
            RETURN NUMBER;
END manag_emps;
/
CREATE REPLACE PACKAGE BODY manage_emps
IS
BEGIN
Update emp
SET sal=|sal+p-raise_amt)+sal WHERE empno= v_id;
END;
PROCEDURE insert_emp
  (p_deptno NUMBER, p-sal NUMBER)
IS
BEGIN
INSERT INTO emp(empno, deptno,sal) VALUES(v_id, p_deptno, p_sal);
END insert emp;
PROCEDURE delete_emp
IS
BEGIN
DELETE FROM emp WHERE empno=v_id
END delete_emp;
PROCEDURE. Update_emp.
IS
V_sal NUMBER (10,2);
V_raise NUMBER(10,2);
BEGIN
SELECT Sal INTO v_sal FROM emp WHERE empno=v_id;
IF        v_sal<500 THEN             V_raise:=0. 05;
ELSIF   v_sal<1000 THEN          V_raise:=0. 07;
ELSE    V_raise:=0. 04
END IF;
Update_sal(v_raise);
END update_emp.
FUNCTION calc_tax
(p_sal NUMBER)
RETURN NUMBER
IS
BEGIN
            RETURN p_sal* tax-rate;
            END calc_tax;
END MANAGE_emp;
/
      What is the name of the private procedure in the package?
  1. CALC_TAX
  2. INSERT_EMP
  3. UPDATE_SAL
  4. DELETE_EMP
  5. UPDATE_EMP
  6. MANAGE_EMP

23.  Examine the code:
CREATE OR REPLACE TRIGGER update_emp
AFTER UPDATE ON emp
BEGIN
INSERT INTO audit_table (who, audited)
VALUES(USER, SYSDATE);
END;
      You issue an update command on the EMP table that result in changing ten rows.  How many rows are inserted into the AUDIT_TABLE?
a.             1
b.            10
c.             none
d.            Value equal to the  number of rows in the EMP table

24.  All users currently have INSERT privileges on the PLAYER table. You want only your users to insert into this table using the ADD_PLAYER procedure.  Which two actions must you take?
  1. GRANT SELECT ON ADD_PLAYER TO PUBLIC;
  2. GRANT EXECUTE ON ADD_PLAYER TO PUBLIC;
  3. GRANT INSERT ON PLAYER TO PUBLIC;
  4. GRANT EXECUTE, INSERT ON ADD_PLAYER TO PUBLIC;
  5. REVOKE INSERT ON PLAYER FROM PUBLIC;

25.  Which oracle supply package allows you to run jobs that use defined times?
  1. DBMS_JOB
  2. DBMS_RUN
  3. DBMS_PIPE
  4. DBMS_SQL

26.  You need to drop a table from within a stored procedure.  How do you implement this?
  1. You cannot drop a table from a stored procedure.
  2. Use the DROP command in the procedure to drop the table.
  3. Use the DBMS_DDL packaged routines in the procedure to drop the table.
  4. Use the DBMS_SQL packaged routines in the procedure to drop the table. ans
  5. Use the DBMS_DROP packaged routines in the procedure to drop the table.

27.  Which data dictionary view gives you the names and the source code of all the procedures you have created?
  1. USER_SOURCE ans
  2. USER_OBJECTS
  3. USER_PROCEDURES
  4. USER_SUBPROGRAMS

28.  Examine this package:
CREATE OR REPLACE PACKAGE BB_PACK
IS
V_MAX_TEAM_SALARY NUMBER(12,2);
PROCEDURE ADD_PLAYER(V_ID IN NUMBER, V_LAST_NAME)
VARCHAR2(V_SALARY NUMBER);
END BB_PACK;
/
CREATE OR REPLACE PACKAGE BODY BB_PACK
IS
V_PLAYER_AVG NUMBER(4,3);
PROCEDURE UPD_PLAYER_STAT
V_ID IN NUMBER, V_AB IN NUMBER DEFAULT4, V_HITS IN NUMBER)
IS
BEGIN
UPDATE PLAYER_BAT_STAT
SET ADD_BAT=ADD_BATS+V_AB,
HITS=HITS+V_HITS
WHERE PLAYER_ID=V_ID;
COMMIT;
VALIDATE_PLAYER_STAT(V_ID);
END UPD_PLAYER_STAT;
PROCEDURE ADD_PLAYER
(V_ID IN NUMBER, V_LAST_NAME, VARCHAR2, V_SALARY IN NUMBER);
IS
BEGIN
INSERT INTO PLAYER (ID, LAST_NAME, SALARY) VALUES(V_ID, V_LAST_NAME, V_SALARY);
UPD_PLAYER_STAT(V_ID,0,0);
END ADD_PLAYER;
END BB_PACK;
Which kind of packaged variable is V_MAX_TEAM_SALARY?
  1. PRIVATE
  2. PUBLIC ans
  3. IN
  4. OUT

29.  Examine this trigger:
CREATE OR REPLACE TRIGGER UPD_TEAM_SALARY
AFTER INSERT OR UPDATE OR DELETE ON PLAYER
FOR EACH ROW
BEGIN
UPDATE TEAM
SET TOT_SALARY=TOT_SALARY+:NEW SALARY.
WHERE ID=:NEW:TEAM_ID;
You will be adding additional code later but for now you want the current block to fire when updating the salary column. Which solution should you use to verify that the user is performing an update on the salary column?
  1. ROW_UPDATE('SALARY')
  2. UPDATING('SALARY') ans
  3. CHANGING('SALARY')
  4. COLUMN_UPDATE('SALARY')

30.  Examine this package:
CREATE OR REPLACE PACKAGE discounts IS
G_ID NUMBER:=7839;
DISCOUNT_RATE NUMBER 0. 00;
PROCEDURE DISPLAY_PRICE (V_PRICE NUMBER);
END DISCOUNTS;
/
CREATE OR REPLACE PACKAGE BODY discounts
IS
PROCEDURE DISPLAY_PRICE (V_PRICE_NUMBER)
IS
BEGIN DBMS_OUTPUT.PUT_LINE('DISCOUNTED||2_4 (V_PRICENVL(DISCOUNT_RATE, 1)))
END DISPLAY_PRICE;
BEGIN DISCOUNT_RATE;=0. 10;
END DISCOUNTS;
/
Which statement is true?
  1. The value of DISCOUNT_RATE always remain 0.00 in a session.
  2. The value of DISCOUNT_RATE is set to 0.10 each time the package is invoked in a session.
  3. The value of DISCOUNT_RATE is set to 1 each time the procedure DISPLAY_PRICE is invoked.
  4. The value of DISCOUNT_RATE is set to 0.10 when the package is invoked for the first time in a session. ans

31.  Examine this package:
CREATE OR REPLACE PACKAGE BB_PACK
V_MAX_TEAM_SALARY NUMBER(12,2);
PROCEDURE ADD_PLAYER(V_ID IN NUMBER, V_LAST_NAME
VARCHAR2, V_SALARY NUMBER);
DB_PACK;/ CREATE OR REPLACE PACKAGE BODY BB_PACK
IS
V_WHERE_AVG NUMBER(4,3);
PROCEDURE UPD_PLAYER_STAT
(V_ID IN NUMBER, V_AVG IN NUMBER DEFAULT 4,V_HITS IN NUMBER)
IS
BEGIN
UPDATE PLAYER_BAT_STAT
SET AT_BATS=AT_BATS+V_AB,
HITS=HITS+V_HITS
WHERE PLAYER_ID=V_ID;
COMMIT;
VALIDATE_PLAYER_STAT(V_ID);
END UPD_PLAYER_STAT;
PROCEDURE ADD-PLAYER
(V_ID IN NUMBER,  V_LAST_NAME VARCHAR2, V_SALARY NUMBER)
IS
BEGIN
INSERT INTO PLAYER(ID, LAST_NAME, SALARY) VALUES(V_ID, V_LAST_NAME, V_SALARY);
UPD_PLAYER_STAT(V_ID,0,0);
END ADD_PLAYER;
END BB_PACK;
An outside procedure VALIDATE_PLAYER_STAT is executed from this package.  What will happen         when this procedure changes?
  1. The package specification is dropped.
  2. The package specification is invalidated.
  3. The package is invalid to begin with.
  4. The package body is invalidated ans

1. Examine this function:
CREATE OR REPLACE FUNCTION CALC_PLAYER_AVG
 (V_ID in PLAYER_BAT_STAT.PLAYER_ID%TYPE)
  RETURN NUMBER IS V_AVG NUMBER;
BEGIN
  SELECT HITS / AT_BATS INTO V_AVG
  FROM PLAYER_BAT_STAT
  WHERE PLAYER_ID = V_ID;
  RETURN (V_AVG);
 END;
Which statement will successfully invoke this function in SQL *Plus?
A.    SELECT CALC_PLAYER_AVG(PLAYER_ID) FROM PLAYER_BAT_STAT;
B.    EXECUTE CALC_PLAYER_AVG(31);
C.    CALC_PLAYER('RUTH');
D.    CALC_PLAYER_AVG(31);
E.    START CALC_PLAYER_AVG(31)           Ans:  a

2.   Which three are true statements about dependent objects? (Choose three)
  1. Invalid objects cannot be described.
  2. An object with status of invalid cannot be a referenced object.
  3. The Oracle server automatically records dependencies among objects.
  4. All schema objects have a status that is recorded in the data dictionary.
  5. You can view whether an object is valid or invalid in the USER_STATUS data dictionary view.
  6. You can view whether an object is valid or invalid in the USER_OBJECTS data dictionary view. Ans:  cdf

3. You have created a stored procedure DELETE_TEMP_TABLE that uses dynamic SQL to remove a table in your schema. You have granted the EXECUTE privilege to user A on this procedure. When user A executes the DELETE_TEMP_TABLE procedure, under whose privileges are the operations performed by default?
  1. SYS privileges
  2. Your privileges
  3. Public privileges
  4. User A's privileges
  5. User A cannot execute your procedure that has dynamic SQL. Ans:  b

4. Examine this code:
CREATE OR REPLACE PRODECURE add_dept (p_dept_name VARCHAR2 DEFAULT 'placeholder', p_location VARCHAR2 DEFAULT 'Boston')
IS BEGIN INSERT INTO departments VALUES (dept_id_seq.NEXTVAL, p_dept_name, p_location); END add_dept; /
Which three are valid calls to the add_dep procedure? (Choose three)
  1. add_dept;
  2. add_dept('Accounting');
  3. add_dept(, 'New York');
  4. add_dept(p_location=>'New York');        Ans:  abd

5. Which two statements about packages are true? (Choose two)
  1. Packages can be nested.
  2. You can pass parameters to packages.
  3. A package is loaded into memory each time it is invoked.
  4. The contents of packages can be shared by many applications.
  5. You can achieve information hiding by making package constructs private. Ans:  de

6. Which two programming constructs can be grouped within a package? (Choose two)
  1. Cursor
  2. Constant
  3. Trigger
  4. Sequence
View                       Ans:  ab

7. Which two statements describe the state of a package variable after executing the package in which it is declared? (Choose two)
  1. It persists across transactions within a session.
  2. It persists from session to session for the same user.
  3. It does not persist across transaction within a session.
  4. It persists from user to user when the package is invoked.
  5. It does not persist from session to session for the same user.   Ans:  ae

8. Which code can you use to ensure that the salary is not increased by more than 10% at a time nor is it ever decreased?
  1. ALTER TABLE emp ADD CONSTRAINT ck_sal CHECK (sal BETWEEN sal AND  sal c1.1);
  2. CREATE OR REPLACE TRIGGER check_sal BEFORE UPDATE OF sal ON emp FOR EACH ROW WHEN (new.sal < old.sal OR new.sal > old.sal * 1.1) BEGIN RAISE_APPLICATION_ERROR ( - 20508, 'Do not decrease salary not increase by more than 10%'); END;
  3. CREATE OR REPLACE TRIGGER check_sal BEFORE UPDATE OF sal ON emp WHEN (new.sal < old.sal OR new.sal > old.sal * 1.1) BEGIN RAISE_APPLICATION_ERROR ( - 20508, 'Do not decrease salary not increase by more than 10%'); END;
  4. CREATE OR REPLACE TRIGGER check_sal AFTER UPDATE OR sal ON emp WHEN (new.sal < old.sal OR -new.sal > old.sal * 1.1) BEGIN RAISE_APPLICATION_ERROR ( - 20508, 'Do not decrease salary not increase by more than 10%'); END;      Ans:  b

9.   Examine this code:
CREATE OR REPLACE PACKAGE bonus IS g_max_bonus NUMBER := .99;
FUNCTION calc_bonus (p_emp_id NUMBER) RETURN NUMBER;
FUNCTION calc_salary (p_emp_id NUMBER) RETURN NUMBER; END;

CREATE OR REPLACE PACKAGE BODY bonus IS v_salary employees.salary%TYPE;
v_bonus employees.commission_pct%TYPE; FUNCTION calc_bonus (p_emp_id NUMBER) RETURN NUMBER IS
BEGIN
SELECT salary, commission_pct INTO v_salary, v_bonus FROM employees WHERE employee_id = p_emp_id; RETURN v_bonus * v_salary; END calc_bonus FUNCTION calc_salary (p_emp_id NUMBER) RETURN NUMBER IS
BEGIN
SELECT salary, commission_pct INTO v_salary, v_bonus FROM employees WHERE employees RETURN v_bonus * v_salary + v_salary;
END cacl_salary;
END bonus; /
Which statement is true?
  1. You can call the BONUS.CALC_SALARY packaged function from an INSERT command against EMPLOYEES table.
  2. You can call the BONUS.CALC_SALARY packaged function from a SELECT command against EMPLOYEES table.
  3. You can call the BONUS.CALC_SALARY packaged function form a DELETE command against EMPLOYEES table.
  4. You can call the BONUS.CALC_SALARY packaged function from an UPDATE command against EMPLOYEES table.            Ans:  b

10. Which statement is valid when removing procedures?
  1. Use a drop procedure statement to drop a standalone procedure.
  2. Use a drop procedure statement to drop a procedure that is part of a package. Then recompile the package specification.
  3. Use a drop procedure statement to drop a procedure that is part of a package. Then recompile the package body.
  4. For faster removal and re-creation, do not use a drop procedure statement. Instead, recompile the procedure using the alter procedure statement with the REUSE SETTINGS clause.                        Ans:  a

11. Examine this package:
CREATE OR REPLACE PACKAGE BB:PACK IS V_MAX_TEAM:SALAR NUMBER(12,2);
PROCEDURE ADD_PLAYER(V_ID IN NUMBER, V_LAST_NAME VARCHAR2, V_SALARY NUMBER);
END BB_PACK; /
CREATE OR REPLACE PACKAGE BODY BB_PACK IS PROCEDURE UPD_PLAYER_STAT (V_ID IN NUMBER, V_AB IN NUMBER DEFAULT 4, V_HITS IN NUMBER) IS BEGIN UPDATE PLAYER_BAT_STAT SET AT_BATS = AT_BATS + V_AB, HITS = HITS + V_HITS WHERE PLAYER_ID = V_ID;
COMMIT;
END UPD_PLAYER_STAT;
PROCEDURE ADD_PLAYER (V_ID IN NUMBER, V_LAST_NAME VARCHAR2, V_SALARY NUMBER) IS BEGIN INSERT INTO PLAYER(ID,LAST_NAME,SALARY) VALUES (V_ID, V_LAST_NAME, V_SALARY);
UPD_PLAYER_STAT(V_ID,0,0); END ADD_PLAYER;
END BB_PACK;
You make a change to the body of the BB_PACK package. The BB_PACK body is recompiled.
What happens if the stand alone procedure VALIDATE_PLAYER_STAT references this package?
a.     VALIDATE_PLAYER_STAT cannot recompile and must be recreated.
b.    VALIDATE_PLAYER_STAT is not invalidated.
c.     VALDIATE_PLAYER_STAT is invalidated.
d.    VALIDATE_PLAYER_STAT and BB_PACK are invalidated.          Ans:  b

12. You need to create a trigger on the EMP table that monitors every row that is changed and places this information into the AUDIT_TABLE. What type of trigger do you create?
A.    FOR EACH ROW trigger on the EMP table.
B.    Statement-level trigger on the EMP table.
C.    FOR EACH ROW trigger on the AUDIT_TABLE table.
D.    Statement-level trigger on the AUDIT_TABLE table.
E.    FOR EACH ROW statement-level trigger on the EMP table. Ans:  a

13. Which statements are true? (Choose all that apply)
  1. If errors occur during the compilation of a trigger, the trigger is still created.
  2. If errors occur during the compilation of a trigger you can go into SQL *Plus and query the USER_TRIGGERS data dictionary view to see the compilation errors.
  3. If errors occur during the compilation of a trigger you can use the SHOW ERRORS command within iSQL *Plus to see the compilation errors.
  4. If errors occur during the compilation of a trigger you can go into SQL *Plus and query the USER_ERRORS data dictionary view to see compilation errors. Ans:  acd

14. Which two dictionary views track dependencies? (Choose two)
  1. USER_SOURCE
  2. UTL_DEPTREE.
  3. USER_OBJECTS
  4. DEPTREE_TEMPTAB
  5. USER_DEPENDENCIES
  6. DBA_DEPENDENT_OBJECTS  Ans:  de

15. Given a function CALCTAX:
CREATE OR REPLACE FUNCTION calctax (sal NUMBER) RETURN NUMBER IS
BEGIN RETURN (sal * 0.05); END;
If you want to run the above function from the SQL *Plus prompt, which statement is true?
  1. You need to execute the command CALCTAX(1000);
  2. You need to execute the command EXECUTE FUNCTION calctax;
  3. You need to create a SQL *Plus environment variable X and issue the command :X := CALCTAX(1000);
  4. You need to create a SQL *Plus environment variable X and issue the command EXECUTE :X := CALCTAX;
  5. You need to create a SQL *Plus environment variable X and issue the command EXECUTE :X := CALCTAX(1000); Ans:  d

16. What happens during the execute phase with dynamic SQL for INSERT, UPDATE, and DELETE operations?
  1. The rows are selected and ordered.
  2. The validity of the SQL statement is established.
  3. An area of memory is established to process the SQL statement.
  4. The SQL statement is run and the number of rows processed is returned.
  5. The area of memory established to process the SQL statement is released. Ans:  d

17. What part of a database trigger determines the number of times the trigger body executes?
  1. Trigger type
  2. Trigger body
  3. Trigger event
  4. Trigger timing Ans:  a

18. Examine this code:
CREATE OR REPLACE FUNCTION gen_email_name (p_first_name VARCHAR2, p_last_name VARCHAR2, p_id NUMBER) RETURN VARCHAR2 is v_email_name VARCHAR2(19);
BEGIN v_email_home := SUBSTR(p_first_name, 1, 1) || SUBSTR(p_last_name, 1, 7) || '@Oracle.com';
UPDATE employees SET email = v_email_name WHERE employee_id = p_id;
RETURN v_email_name; END;
You run this SELECT statement:
SELECT first_name, last_name gen_email_name(first_name, last_name, 108) EMAIL FROM employees;
What occurs?
  1. Employee 108 has his email name updated based on the return result of the function.
  2. The statement fails because functions called from SQL expressions cannot perform DML.
  3. The statement fails because the functions does not contain code to end the transaction.
  4. The SQL statement executes successfully, because UPDATE and DELETE statements are ignoring in stored functions called from SQL expressions.
  5. The SQL statement executes successfully and control is passed to the calling environment. Ans:  b

19. Which table should you query to determine when your procedure was last compiled?
A.    USER_PROCEDURES
B.    USER_PROCS
C.    USER_OBJECTS
D.    USER_PLSQL_UNITS Ans:  c

20. Examine this code:
CREATE OR REPLACE TRIGGER secure_emp BEFORE LOGON ON employees
BEGIN
IF (TO_CHAR(SYSDATE, 'DY') IN ('SAT', 'SUN')) OR (TO_CHAR(SYSDATE, 'HH24:MI') NOT BETWEEN '08:00' AND '18:00')
THEN RAISE_APPLICATION_ERROR (-20500, 'You may insert into the EMPLOYEES table only during business hours.');
END IF; END; /
What type of trigger is it?
A.    DML trigger
B.    INSTEAD OF trigger
C.    Application trigger
D.    System event trigger
E.    This is an invalid trigger. Ans:  e

21. Examine this package:
CREATE OR REPLACE PACKAGE discounts IS g_id NUMBER := 7829;
discount_rate NUMBER := 0.00;
PROCEDURE display_price (p_price NUMBER);
END discounts; /
CREATE OR REPLACE PACKAGE BODY discounts IS PROCEDURE display_price (p_price NUMBER) IS BEGIN DBMS_OUTPUT.PUT_LINE('Discounted '|| TO_CHAR(p_price*NVL(discount_rate, 1)));
END display_price;
BEGIN discount_rate := 0.10;
END discounts; /
Which statement is true?
A.    The value of DISCOUNT_RATE always remains 0.00 in a session.
B.    The value of DISCOUNT_RATE is set to 0.10 each time the package is invoked in a session.
C.    The value of DISCOUNT_RATE is set to 1.00 each time the procedure DISPLAY_PRICE is invoked.
D.    The value of DISCOUNT_RATE is set to 0.10 when the package is invoked for the first time in a session. Ans:  d

22. Examine this code:
CREATE OR REPLACE TRIGGER update_emp AFTER UPDATE ON emp BEGIN INSERT INTO audit_table (who, dated) VALUES (USER, SYSDATE); END;
You issue an UPDATE command in the EMP table that result in changing 10 rows. How many rows are inserted into the AUDIT_TABLE?
  1. 1
  2. 10
  3. None
  4. A value equal to the number of rows in the EMP table. Ans:  a

23. Examine this package:
CREATE OR REPLACE PACKAGE BB_PACK IS V_MAX_TEAM_SALARY NUMBER(12,2);
PROCEDURE ADD_PLAYER(V_ID IN NUMBER, V_LAST_NAME VARCHAR2, V_SALARY_NUMBER; END BB_PACK; /
CREATE OR REPLACE PACKAGE BODY BB_PACK IS
PROCEDURE UPD_PLAYER_STAT (V_ID IN NUMBER, V_AB IN NUMBER DEFAULT 4, V_HITS IN NUMBER) IS
BEGIN UPDATE PLAYER_BAT_STAT SET AT_BATS = AT_BATS + V_AB, HITS = HITS + V_HITS WHERE PLAYER_ID = V_ID) COMMIT;
END UPD_PLAYER_STAT;
PROCEDURE ADD_PLAYER (V_ID IN NUMBER, V_LAST_NAME VARCHAR2, V_SALARY NUMBER) IS BEGIN INSERT INTO PLAYER(ID,LAST_NAME,SALARY) VALUES (V_ID, V_LAST_NAME, V_SALARY);
UPD_PLAYER_STAT(V_ID,0.0);
END ADD_PLAYER; END BB_PACK;
Which statement will successfully assign $75,000,000 to the V_MAX_TEAM_SALARY variable from within a stand-alone procedure?
A.    V_MAX_TEAM_SALARY := 7500000;
B.    BB_PACK.ADD_PLAYER.V_MAX_TEAM_SALARY := 75000000;
C.    BB_PACK.V_MAX_TEAM_SALARY := 75000000;
D.    This variable cannot be assigned a value from outside the package. Ans:  c

24. There is a CUSTOMER table in a schema that has a public synonym CUSTOMER and you are granted all object privileges on it. You have a procedure PROCESS_CUSTOMER that processes customer information that is in the public synonym CUSTOMER table. You have just created a new table called CUSTOMER within your schema. Which statement is true?
  1. Creating the table has no effect and procedure PROCESS_CUSTOMER still accesses data from public synonym CUSTOMER table.
  2. If the structure of your CUSTOMER table is the same as the public synonym CUSTOMER table then the procedure PROCESS_CUSTOMER is invalidated and gives compilation errors.
  3. If the structure of your CUSTOMER table is entirely different from the public synonym CUSTOMER table then the procedure PROCESS_CUSTOMER successfully recompiles and accesses your CUSTOMER table.
  4. If the structure of your CUSTOMER table is the same as the public synonym CUSTOMER table then the procedure PROCESS_CUSTOMER successfully recompiles when invoked and accesses your CUSTOMER table. Ans:  d

25. Which two statements about packages are true? (Choose two)
  1. Both the specification and body are required components of a package.
  2. The package specification is optional, but the package body is required.
  3. The package specification is required, but the package body is optional.
  4. The specification and body of the package are stored together in the database.
  5. The specification and body of the package are stored separately in the database. Ans:  ce

26. When creating a function in SQL *Plus, you receive this message:
"Warning: Function created with compilation errors."
Which command can you issue to see the actual error message?
  1. SHOW FUNCTION_ERROR
  2. SHOW USER_ERRORS
  3. SHOW ERRORS
  4. SHOW ALL_ERRORS   Ans:  c

27. Which four triggering events can cause a trigger to fire? (Choose four)
  1. A specific error or any errors occurs.
  2. A database is shut down or started up.
  3. A specific user or any user logs on or off.
  4. A user executes a CREATE or an ALTER table statement.
  5. A user executes a SELECT statement with an ORDER BY clause.
  6. A user executes a JOIN statement that uses four or more tables. Ans:  abcd

28. Examine this procedure:
CREATE OR REPLACE PROCEDURE ADD_PLAYER (V_ID IN NUMBER,   V_LAST_NAME VARCHAR2) IS
BEGIN
INSERT INTO PLAYER (ID,LAST_NAME) VALUES (V_ID, V_LAST_NAME);               COMMIT;   END;
This procedure must invoke the UPD_BAT_STAT procedure and pass a parameter.
Which statement, when added to the above procedure will successfully invoke the UPD_BAT_STAT procedure?
A.    EXECUTE UPD_BAT_STAT(V_ID);
B.    UPD_BAT_STAT(V_ID);
C.    RUN UPD_BAT_STAT(V_ID);
D.    START UPD_BAT_STAT(V_ID); Ans:  b

29. Which statement about triggers is true?
  1. You use an application trigger to fire when a DELETE statement occurs.
  2. You use a database trigger to fire when an INSERT statement occurs.
  3. You use a system event trigger to fire when an UPDATE statement occurs.
  4. You use INSTEAD OF trigger to fire when a SELECT statement occurs. Ans:  b

30. You want to create a PL/SQL block of code that calculates discounts on customer orders. This code will be invoked from several places, but only within the program unit ORDERTOTAL. What is the most appropriate location to store the code that calculates the discounts?
  1. A stored procedure on the server.
  2. A block of code in a PL/SQL library.
  3. A standalone procedure on the client machine.
  4. A block of code in the body of the program unit ORDERTOTAL.
  5. A local subprogram defined within the program unit ORDERTOTAL. Ans: e

31. Which type of argument passes a value from a procedure to the calling environment?
  1. VARCHAR2
  2. BOOLEAN
  3. OUT
  4. IN Ans: c

32. You create a DML trigger. For the timing information, which is valid with a DML trigger?
  1. DURING
  2. INSTEAD
  3. ON SHUTDOWN
  4. BEFORE
  5. ON STATEMENT EXECUTION Ans: d

33. You are about to change the arguments of the CALC_TEAM_AVG function. Which dictionary view can you query to determine the names of the procedures and functions that invoke the CALC_TEAM_AVG function?
  1. USER_PROC_DEPENDS
  2. USER_DEPENDENCIES
  3. USER_REFERENCES  
  4. USER_SOURCE Ans: b

34. A CALL statement inside the trigger body enables you to call ______.
  1. A package.
  2. A stored function.
  3. A stored procedure.
  4. Another database trigger. Ans: c

35. You need to remove the database trigger BUSINESS_HOUR. Which command do you use to remove the trigger in the SQL *Plus environment?
  1. DROP TRIGGER business_hour;
  2. DELETE TRIGGER business_hour;
  3. REMOVE TRIGGER business_hour;
  4. ALTER TRIGGER business_hour REMOVE;
  5. DELETE FROM USER_TRIGGERS WHERE TRIGGER_NAME = 'BUSINESS_HOUR'; Ans: a

36. How can you migrate from a LONG to a LOB data type for a column?
  1. Use the DBMS_MANAGE_LOB.MIGRATE procedure.
  2. Use the UTL_MANAGE_LOB.MIGRATE procedure.
  3. Use the DBMS_LOB.MIGRATE procedure.
  4. Use the ALTER TABLE command.
  5. You cannot migrate from a LONG to a LOB date type for a column. Ans: d

37. Examine this procedure:
CREATE OR REPLACE PROCEDURE INSERT_TEAM (V_ID in NUMBER, V_CITY in VARCHAR2 DEFAULT 'AUSTIN', V_NAME in VARCHAR2) IS
BEGIN
INSERT INTO TEAM (id, city, name) VALUES (v_id, v_city, v_name); COMMIT;
END
Which two statements will successfully invoke this procedure in SQL *Plus? (Choose two)
  1. EXECUTE INSERT_TEAM;
  2. EXECUTE INSERT_TEAM(3, V_NAME=>'LONGHORNS', V_CITY=>'AUSTIN');
  3. EXECUTE INSERT_TEAM(3, 'AUSTIN','LONGHORNS');
  4. EXECUTE INSERT_TEAM (V_ID := V_NAME := 'LONGHORNS', V_CITY := 'AUSTIN'); E. EXECUTE INSERT_TEAM (3, 'LONGHORNS'); Ans: bc

38. To be callable from a SQL expression, a user-defined function must do what?
A.    Be stored only in the database.
B.    Have both IN and OUT parameters.
C.    Use the positional notation for parameters.
D.    Return a BOOLEAN or VARCHAR2 data type. Ans: c

39. Which two describe a stored procedure? (Choose two)
A.    A stored procedure is typically written in SQL.
B.    A stored procedure is a named PL/SQL block that can accept parameters.
C.    A stored procedure is a type of PL/SQL subprogram that performs an action.
D.    A stored procedure has three parts: the specification, the body, and the exception handler part.
E.    The executable section of a stored procedure contains statements that assign values, control execution, and return values to the calling environment. Ans: bc

40. Examine this code:
CREATE OR REPLACE PROCEDURE add_dept (p_name departments.department_name%TYPE DEFAULT 'unknown', p_loc departments.location_id%TYPE DEFAULT 1700) IS.
BEGIN
INSERT INTO departments(department_id, department_name, loclation_id) VALUES(dept_seq.NEXTVAL,p_name, p_loc); END add_dept; /
You created the add_dept procedure above, and you now invoke the procedure in SQL *Plus.
Which four are valid invocations? (Choose four)
A.    EXECUTE add_dept(p_loc=>2500)
B.    EXECUTE add_dept('Education', 2500)
C.    EXECUTE add_dept('2500', p_loc =>2500)
D.    EXECUTE add_dept(p_name=>'Education', 2500)
E.    EXECUTE add_dept(p_loc=>2500, p_name=>'Education') Ans: abce

41. Which three are valid ways to minimize dependency failure? (Choose three)
  1. Querying with the SELECT * notification.
  2. Declaring variables with the %TYPE attribute.
  3. Specifying schema names when referencing objects.
  4. Declaring records by using the %ROWTYPE attribute.
  5. Specifying package.procedure notation while executing procedures. Ans: abd

42. Which two dopes the INSTEAD OF clause in a trigger identify? (Choose two)
  1. The view associated with the trigger.
  2. The table associated with the trigger.
  3. The event associated with the trigger.
  4. The package associated with the trigger.
  5. The statement level or for each row association to the trigger. Ans: ac

43. Examine this package:
CREATE OR REPLACE PACKAGE manage_emps IS tax_rate CONSTANT NUMBER(5,2) := .28;
v_id NUMBER;
PROCEDURE insert_emp (p_deptno NUMBER, p_sal NUMBER);
PROCEDURE delete_emp; PROCEDURE update_emp;
FUNCTION calc_tax (p_sal NUMBER) RETURN NUMBER;
END manage_emps;

CREATE OR REPLACE PACKAGE BODY manage_emps IS PROCEDURE update_sal (p_raise_amt NUMBER) IS BEGIN
UPDATE emp SET sal = (sal * p_raise_emt) + sal WHERE empno = v_id;
END;
PROCEDURE insert_emp (p_deptno NUMBER, p_sal NUMBER) IS BEGIN INSERT INTO emp(empno, deptno, sal) VALYES(v_id, p_depntno, p_sal); END insert_emp;
PROCEDURE delete_emp IS BEGIN DELETE FROM emp WHERE empno = v_id;
END delete_emp; PROCEDURE update_emp IS v_sal NUMBER(10, 2); v_raise NUMBER(10, 2);
BEGIN
SELECT sal INTO v_sal FROM emp WHERE empno = v_id;
IF v_sal < 500 THEN v_raise := .05;
ELSIF v_sal < 1000 THEN v_raise := .07;
ELSE v_raise := .04;
END IF;
update_sal(v_raise);
END update_emp;
FUNCTION calc_tax (p_sal NUMBER) RETURN NUMBER IS BEGIN RETURN p_sal * tax_rate;
END calc_tax;
END manage_emps; /
What is the name of the private procedure in this package?
A.    CALC_TAX
B.    INSERT_EMP
C.    UPDATE_SAL
D.    DELETE_EMP
E.    UPDATE_EMP
F.    MANAGE_EMPS Ans: c

44. What can you do with the DBMS_LOB package?
A.    Use the DBMS_LOB.WRITE procedure to write data to a BFILE.
B.    Use the DBMS_LOB.BFILENAME function to locate an external BFILE.
C.    Use the DBMS_LOB.FILEEXISTS function to find the location of a BFILE.
D.    Use the DBMS_LOB.FILECLOSE procedure to close the file being accessed. Ans: d

45. Examine this package:
CREATE OR REPLACE PACKAGE BB_PACK IS V_MAX_TEAM_SALARY NUMBER(12,2); PROCEDURE ADD_PLAYER(V_ID IN NUMBER, V_LAST_NAME VARCHAR2, V_SALARY NUMBER); END BB_PACK;
CREATE OR REPLACE PACKAGE BODY BB_PACK IS V_PLAYER_AVG NUMBER(4,3); PROCEDURE UPD_PLAYER_STAT V_ID IN NUMBER, V_AB IN NUMBER DEFAULT 4, V_HITS IN NUMBER) IS BEGIN UPDATE PLAYER_BAT_STAT SET AT_BATS = AT_BATS + V_AB, HITS = HITS + V_HITS WHERE PLAYER_ID = V_ID; COMMIT;
VALIDATE_PLAYER_STAT(V_ID);
 END UPD_PLAYER_STAT;
 PROCEDURE ADD_PLAYER (V_ID IN NUMBER, V_LAST_NAME VARCHAR2, V_SALARY NUMBER) IS BEGIN INSERT INTO PLAYER(ID,LAST_NAME,SALARY) VALUES (V_ID, V_LAST_NAME, V_SALARY);
UPD_PLAYER_STAT(V_ID,0,0);
END ADD_PLAYER;
END BB_PACK /
Which statement will successfully assign .333 to the V_PLAYER_AVG variable from a procedure outside the package?
  1. V_PLAYER_AVG := .333;
  2. BB_PACK.UPD_PLAYER_STAT.V_PLAYER_AVG := .333;
  3. BB_PACK.V_PLAYER_AVG := .333;
  4. This variable cannot be assigned a value from outside of the package. Ans: d

46. Examine this code:
CREATE OR REPLACE PACKAGE comm_package IS g_comm NUMBER := 10;
PROCEDURE reset_comm(p_comm IN NUMBER);
ND comm_package;
User Jones executes the following code at 9:01am:           
EXECUTE comm_package.g_comm := 15
User Smith executes the following code at 9:05am:
EXECUTE comm_paclage.g_comm := 20
Which statement is true?
  1. g_comm has a value of 15 at 9:06am for Smith.
  2. g_comm has a value of 15 at 9:06am for Jones.
  3. g_comm has a value of 20 at 9:06am for both Jones and Smith.
  4. g_comm has a value of 15 at 9:03 am for both Jones and Smith.
  5. g_comm has a value of 10 at 9:06am for both Jones and Smith.
  6. g_comm has a value of 10 at 9:03am for both Jones and Smith    Ans: b

47. Examine this code:
CREATE OR REPLACE FUNCTION gen_email_name (p_first_name VARCHAR2, p_last_name VARCHAR2, p_id NUMBER) RETURN VARCHAR2 IS v_email_name VARCHAR2(19=; BEGIN v_email_name := SUBSTR(p_first_name, 1, 1) || SUBSTR(p_last_name, 1, 7) || '@Oracle.com'; UPDATE employees SET email = v_email_name WHERE employee_id = p_id; RETURN v_email_name; END;
Which statement removes the function?
  1. DROP gen_email_name;
  2. REMOVE gen_email_name;
  3. DELETE gen_email_name;
  4. ***MISSING*** Ans: d

48. Examine this procedure:
CREATE OR REPLACE PROCEDURE UPD_BAT_STAT (V_ID IN NUMBER DEFAULT 10, V_AB IN NUMBER DEFAULT 4) IS BEGIN UPDATE PLAYER_BAT_STAT SET AT_BATS = AT_BATS + V_AB WHERE PLAYER_ID = V_ID; COMMIT; END;
Which two statements will successfully invoke this procedure in SQL *Plus? (Choose two)
  1. EXECUTE UPD_BAT_STAT;
  2. EXECUTE UPD_BAT_STAT(V_AB=>10, V_ID=>31);
  3. EXECUTE UPD_BAT_STAT(31, 'FOUR','TWO');
  4. UPD_BAT_STAT(V_AB=>10, V_ID=>31);
  5. RUN UPD_BAT_STAT; Ans: ab

49. Examine this code:
CREATE OR REPLACE PROCEDURE audit_action (p_who VARCHAR2) AS BEGIN INSERT INTO audit(schema_user) VALUES(p_who); END audit_action; /
CREATE OR REPLACE TRIGGER watch_it AFTER LOGON ON DATABASE.
CALL audit_action(ora_login_user) ;
What does this trigger do?
  1. The trigger records an audit trail when a user makes changes to the database.
  2. The trigger marks the user as logged on to the database before an audit statement is issued.
  3. The trigger invoked the procedure audit_action each time a user logs on to his/her schema and adds the username to the audit table.
  4. The trigger invokes the procedure audit_action each time a user logs on to the database and adds the username to the audit table. Ans: d

50. Which view displays indirect dependencies, indenting each dependency?
  1. DEPTREE
  2. IDEPTREE
  3. INDENT_TREE
  4. I_DEPT_TREE Ans: b

51. The OLD and NEW qualifiers can be used in which type of trigger?
  1. Row level DML trigger
  2. Row level system trigger
  3. Statement level DML trigger
  4. Row level application trigger
  5. Statement level system trigger
  6. Statement level application trigger Ans: a

52. Which statement is true?
  1. Stored functions can be called from the SELECT and WHERE clauses only.
  2. Stored functions do not permit calculations that involve database links in a distributed environment.
  3. Stored functions cannot manipulate new types of data, such as longitude and latitude.
  4. Stored functions can increase the efficiency of queries by performing functions in the query rather than in the application. Ans: d

53. Examine the trigger:
CREATE OR REPLACE TRIGGER Emp_count AFTER DELETE ON Emp_tab FOR EACH ROW DELCARE n INTEGER;
BEGIN SELECT COUNT(*) INTO n FROM Emp_tab;
DMBS_OUTPUT.PUT_LINE(' There are now ' || a || ' employees,'); END;
This trigger results in an error after this SQL statement is entered:
DELETE FROM Emp_tab WHERE Empno = 7499;
How do you correct the error?
  1. Change the trigger type to a BEFORE DELETE .
  2. Take out the COUNT function because it is not allowed in a trigger.
  3. Remove the DBMS_OUTPUT statement because it is not allowed in a trigger.
  4. Change the trigger to a statement-level trigger by removing FOR EACH ROW. Ans: d

54. What is true about stored procedures?
A.    A stored procedure uses the DELCLARE keyword in the procedure specification to declare formal parameters.
B.    A stored procedure is named PL/SQL block with at least one parameter declaration in the procedure specification.
C.    A stored procedure must have at least one executable statement in the procedure body.
D.    A stored procedure uses the DECLARE keyword in the procedure body to declare formal parameters. Ans: c

55. Examine this code:
CREATE OR REPLACE PROCEDURE insert_dept (p_location_id NUMBER) IS v_dept_id NUMBER(4);
 BEGIN
     INSERT INTO departments VALUES (5, 'Education', 150, p_location_id);
     SELECT department_id INTO v_dept_id FROM employees WHERE employee_id=99999; END insert_dept; /
CREATE OR REPLACE PROCEDURE insert_location ( p_location_id NUMBER, p_city VARCHAR2) IS
BEGIN
     INSERT INTO locations(location_id, city) VALUES (p_location_id, p_city);
     insert_dept(p_location_id);
END insert_location; /
You just created the departments, the locations, and the employees table. You did not insert any rows. Next you created both procedures. You now invoke the insert_location procedure using the following command:
EXECUTE insert_location (19, 'San Francisco')
What is the result in this EXECUTE command?
A.    The locations, departments, and employees tables are empty.
B.    The departments table has one row. The locations and the employees tables are empty.
C.    The location table has one row. The departments and the employees tables are empty.
D.    The locations table and the departments table both have one row. The employees table is empty. Ans: a

56. The creation of which four database objects will cause a DDL trigger to fire? (Choose four)
  1. Index
  2. Cluster
  3. Package
  4. Function
  5. Synonyms
  6. Dimensions
  7. Database links Ans: abcd

57. Which two program declarations are correct for a stored program unit? (Choose two)
A.    CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER
B.    CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER) RETURN NUMBER
C.    CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER)
D.    CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER(10,2)
E.    CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER(10, 2)) Ans: ac

58. You need to implement a virtual private database (vpd). In order to have the vpd functionality, a trigger is required to fire when every user initiates a session in the database. What type of trigger needs to be created?
  1. DML trigger
  2. System event trigger
  3. INSTEAD OF trigger
  4. Application trigger Ans: b

59. You have a row level BEFORE UPDATE trigger on the EMP table. This trigger contains a SELECT statement on the EMP table to ensure that the new salary value falls within the minimum and maximum salary for a given job title. What happens when you try to update a salary value in the EMP table?
A.    The trigger fires successfully.
B.    The trigger fails because it needs to be a row level AFTER UPDATE trigger.
C.    The trigger fails because a SELECT statement on the table being updated is not allowed.
D.    The trigger fails because you cannot use the minimum and maximum functions in a BEFORE UPDATE trigger. Ans: c

60. Examine this code:
CREATE OR REPLACE STORED FUNCTION get_sal (p_raise_amt NUMBER, p_employee_id employees.employee_id%TYPE) RETURN NUMBER.
IS v_salary NUMBER; v_raise NUMBER(8,2); BEGIN SELECT salary INTO v_salary FROM employees WHERE employee_id = p_employee_id; v_raise := p_raise_amt * v_salary; RETURN v_raise; END;
Which statement is true?
  1. This statement creates a stored procedure named get_sal.
  2. This statement returns a raise amount based on an employee id.
  3. This statement creates a stored function named get_sal with a status of invalid.
  4. This statement creates a stored function named get_sal.
  5. This statement fails. Ans: e

61. You need to disable all triggers on the EMPLOYEES table. Which command accomplishes this?
  1. None of these commands; you cannot disable multiple triggers on a table in one command.
  2. ALTER TRIGGERS ON TABLE employees DISABLE;
  3. ALTER employees DISABLE ALL TRIGGERS;
  4. ALTER TABLE employees DISABLE ALL TRIGGERS;  Ans:  d

62. An internal LOB is _____.
  1. A table.
  2. A column that is a primary key.
  3. Stored in the database.
  4. A file stored outside of the database, with an internal pointer to it from a database column. Ans: c

63. Examine this code:
CREATE OR REPLACE FUNCTION calc_sal (p_salary NUMBER) RETURN NUMBER IS v_raise NUMBER(4,2) DEFAULT 1.08;
BEGIN
 RETURN v_raise * p_salary;
END calc_sal; /
Which statement accurately call the stored function CALC_SAL ? (Choose two)
  1. UPDATE employees (calc_sal(salary)) SET salary = salary * calc_sal(salary);
  2. INSERT calc_sal(salary) NOT employees WHERE department_id = 60;
  3. DELETE FROM employees(calc_sal(salary)) WHERE calc_sal(salary) > 1000;
  4. SELECT salary, calc_sal(salary) FROM employees WHERE department_id = 60;
  5. SELECT last_name, salary, calc_sal(salary) FROM employees ORDER BY calc_sal(salary); Ans: de

64. This statement fails when executed:
CREATE OR REPLACE TRIGGER CALC_TEAM_AVG AFTER INSERT ON PLAYER BEGIN
INSERT INTO PLAYER_BATSTAT (PLAYER_ID, SEASON_YEAR,AT_BATS,HITS) VALUES (:NEW.ID, 1997, 0,0); END;
To which type must you convert the trigger to correct the error?
  1. Row.
  2. Statement
  3. ORACLE FORM trigger
  4. Before Ans: a

65. Examine this code:
CREATE OR REPLACE PROCEDURE audit_emp (p_id IN emp_empno%TYPE) IS
 v_id NUMBER;
PROCEDURE log_exec IS BEGIN INSERT INTO log_table (user_id, log_delete) VALUES (USER, SYSDATE); END log_excec;
v_name VARCHAR2(20);
BEGIN
DELETE FROM emp WHERE empno = p_id; log_exec; SELECT ename, empno INTO v_name, v_id FROM emp WHERE empno = p_id; END audit_temp;
Why does this code cause an error when compiled?
  1. An statement is not allowed in a subprogram declaration.
  2. Procedure LOG_EXEC should be declared before any identifiers.
  3. Variable v_name should be declared before declaring the LOG_EXEC procedure.
  4. The LOG_EXEC procedure should be invoked as EXECUTE log_exec with the AUDIT_EMP procedure. Ans: c

66. Examine this code:
CREATE OR REPLACE PACKAGE metric_converter IS c_height CONSTRAINT NUMBER := 2.54; c_weight CONSTRAINT NUMBER := .454; FUNCTION calc_height (p_height_in_inches NUMBER) RETURN NUMBER;
FUNCTION calc_weight (p_weight_in_pounds NUMBER) RETURN NUMBER;
END;
CREATE OR REPLACE PACKAGE BODY metric_converter IS FUNCTION calc_height (p_height_in_inches NUMBER) RETURN NUMBER IS BEGIN RETURN p_height_in_inches * c_height;
END calc_height;
FUNCTION calc_weight (p_weight_in_pounds NUMBER) RETURN NUMBER IS BEGIN RETURN p_weight_in_pounds * c_weight END calc_weight END metric_converter; /
CREATE OR REPLACE FUNCTION calc_height (p_height_in_inches NUMBER) RETURN NUMBER IS BEGIN RETURN p_height_in_inches * metric_converter.c_height; END calc_height; /
Which statement is true?
a.     If you remove the package specification, then the package body and the stand alone stored function CALC_HEIGHT are removed.
b.    If you remove the package body, then the package specification and the stand alone stored function CALC_HEIGHT are removed.
c.     If you remove the package specification, then the package body is removed.
d.    If you remove the package body, then the package specification is removed.
e.     If you remove the stand alone stored function CALC_HEIGHT, then the METRIC_CONVERTER package body and the package specification are removed.
f.     The stand alone function CALC_HEIGHT cannot be created because its name is used in a packaged function. Ans:  c

67. What is a condition predicate in a DML trigger?
A.    A conditional predicate allows you to specify a WHEN-LOGGING-ON condition in the trigger body.
B.    A conditional predicate means you use the NEW and OLD qualifiers in the trigger body as a condition.
C.    A conditional predicate allows you to combine several DBM triggering events into one in the trigger body.
D.    A conditional predicate allows you to specify a SHUTDOWN or STARTUP condition in trigger body. Ans:  c

68. Examine this package specification:
CREATE OR REPLACE PACKAGE concat_all IS v_string VARCHAR2(100);
PROCEDURE combine (p_num_val NUMBER);
PROCEDURE combine (p_date_val DATE);
PROCEDURE combine (p_char_val VARCHAR2, p_num_val NUMBER);
END concat_all; /
Which overloaded COMBINE procedure declaration can be added to this package specification?
a.     PROCEDURE combine;
b.    PROCEDURE combine (p_no NUMBER);
c.     PROCEDURE combine (p_val_1 VARCHAR2, p_val_2 NUMBER;
d.    PROCEDURE concat_all (p_num_val VARCHAR2, p_char_val NUMBER); Ans:  a

69. Local procedure A calls remote procedure B. Procedure B was compiled at 8 A.M. Procedure A was modified and recompiled at 9 A.M. Remote procedure B was later modified and recompiled at 11 A.M.
The dependency mode is set to TIMESTAMP. What happens when procedure A is invoked at 1 P.M?
A.    There is no affect on procedure A and it runs successfully.
B.    Procedure B is invalidated and recompiles when invoked.
C.    Procedure A is invalidated and recompiles for the first time it is invoked.
D.    Procedure A is invalidated and recompiles for the second time it is invoked. Answer

70. Under which two circumstances do you design database triggers? (Choose two)
  1. To duplicate the functionality of other triggers.
  2. To replicate built-in constraints in the Oracle server such as primary key and foreign key.
  3. To guarantee that when a specific operation is performed, related actions are performed.
  4. For centralized, global operations that should be fired for the triggering statement, regardless of which user or application issues the statement. Ans:  cd

71. Examine this procedure
CREATE OR REPLACE PROCEDURE DELETE_PLAYER (V_ID IN NUMBER) IS BEGIN DELETE FROM PLAYER WHERE ID = V_ID EXCEPTION
WHEN STATS_EXITS_EXCEPTION THEN
DBMS_OUTPUT.PUT_LINE ('Cannot delete this player, child records exist in PLAYER_BAT_STAT table');
END;
What prevents this procedure from being created successfully?
  1. A comma has been left after the STATS_EXIST_EXCEPTION exception.
  2. The STATS_EXIST_EXCEPTION has not been declared as a number.
  3. The STATS_EXIST_EXCEPTION has not been declared as an exception.
  4. Only predefined exceptions are allowed in the EXCEPTION section.        Ans:  c

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.