Oracle9i program with pl/sql Sample Questions:
1. 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_exec;
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_emp;
Why does this code cause an error when compiled?
A) An insert statement is not allowed in a subprogram declaration.
B) Variable v_name should be declared before declaring the LOG_EXEC procedure.
C) The LOG_EXEC procedure should be invoked as EXECUTE log_exec with the AUDIT_EMP procedure.
D) Procedure LOG_EXEC should be declared before any identifiers.
2. Which two statements about functions are true? (Choose two.)
A) A stored function that is called from a SOL statement can return a value of any PL/SOL variable data type
B) Client-side functions can be used in SOL statements
C) From SOL*Plus, a function can be executed by giving the command EXECUTE functionname;
D) A function must have a return statement in its body to execute successfully
E) A stored function increases efficiency of queries by performing functions on the server rather than in the application
3. Which table should you query to determine when your procedure was last compiled?
A) USER_PROCS
B) USER_PROCEDURES
C) USER_OBJECTS
D) USER_PLSQL_UNITS
4. 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?
A) A standalone procedure on the client machine.
B) A stored procedure on the server.
C) A local subprogram defined within the program unit ORDERTOTAL.
D) A block of code in a PL/SQL library.
E) A block of code in the body of the program unit ORDERTOTAL.
5. 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 AUDIT_TABLE table.
B) FOR EACH ROW statement-level trigger on the EMPtable.
C) Statement-level trigger on the EMP table.
D) FOR EACH ROW trigger on the EMP table.
E) Statement-level trigger on the AUDIT_TABLE table.
Solutions:
| Question # 1 Answer: B | Question # 2 Answer: D,E | Question # 3 Answer: C | Question # 4 Answer: C | Question # 5 Answer: D |
We're so confident of our products that we provide no hassle product exchange.


By Taylor

