Oracle9i program with pl/sql Sample Questions:
1. 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 results in changing 10 rows.
How many rows are inserted into the AUDIT_TABLE?
A) A value equal to the number of rows in the EMP table.
B) None
C) 10
D) 1
2. 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?
A) SHOW FUNCTION_ERROR
B) SHOW USER_ERRORS
C) SHOW ALL_ERRORS
D) SHOW ERRORS
3. 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?
A) 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.
B) 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.
C) 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.
D) Creating the table has no effect and procedure PROCESS_CUSTOMER still accesses data from public synonym CUSTOMER table.
4. 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?
A) 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;
B) 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;
C) ALTER TABLE emp ADD
CONSTRAINT ck_sal CHECK (sal BETWEEN sal AND sal*1.1);
D) 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;
5. You need to remove the database triggerBUSINESS_HOUR.Which command do you use to remove the trigger in the SQL *Plus environment?
A) DELETE TRIGGER business_hour;
B) ALTER TRIGGER business_hour REMOVE;
C) DROP TRIGGER business_hour;
D) REMOVE TRIGGER business_hour;
E) DELETE FROM USER_TRIGGERS
WHERE TRIGGER_NAME = 'BUSINESS_HOUR';
Solutions:
Question # 1 Answer: D | Question # 2 Answer: D | Question # 3 Answer: C | Question # 4 Answer: B | Question # 5 Answer: C |