View the Exhibit and examine the structure of the AUDIR_CUST table.
Exhibit Missing - CUST_ID and CUST_LIMIT are existing columns in the CUSTOMER table. Examine the following trigger code: Which statement is true about the above trigger?
A.
It gives an error on compilation because it should be a statement-level trigger.
B.
It compiles and fires successfully when the credit limit is updated in the customer table.
C.
It gives an error on compilation because of the commit command in the trigger code.
D.
It compiles successfully, but gives an error when the credit limit is updated in the CUSTOMER table because the PRAGMA AUTONOMOUS_TRANSACTION
I agree with C, but it would give errors also for the :OLD keyword right? because for the insert statement inside row-level trigger it's accepted only the value for :NEW
C is correct , you cant use commit or rollback in the trigger.
The transaction made in trigger is commited by the normal flow of the program that fired the trigger
CREATE TABLE audit_cust (
user_name VARCHAR2(50),
change_time DATE,
cust_id NUMBER,
old_credit_limit NUMBER,
new_credit_limit NUMBER
);
/
Table AUDIT_CUST created.
CREATE OR REPLACE TRIGGER tr_audit_cust AFTER
UPDATE OF salary ON emp1
FOR EACH ROW
BEGIN
INSERT INTO audit_cust (
user_name,
change_time,
cust_id,
old_credit_limit,
new_credit_limit
) VALUES (
user,
sysdate,
:old.employee_id,
:old.salary,
:new.salary
);
COMMIT;
END;
/
Trigger TR_AUDIT_CUST compiled
UPDATE emp1
SET
salary = NULL
WHERE
department_id = '20';
/
ORA-04092: cannot COMMIT in a trigger
ORA-06512: at "HR.TR_AUDIT_CUST", line 16
ORA-04088: error during execution of trigger 'HR.TR_AUDIT_CUST'
D is correct.
It compiles successfully, but gives an error when the credit limit is updated in the CUSTOMER table because the PRAGMA AUTONOMOUS_TRANSACTION statement should be introduced in the trigger.
upvoted 4 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Eli93
2 years, 1 month agocf21
3 years, 2 months agoCosminCof
4 years, 11 months agoPacogas
4 years, 9 months agoHexaDev
4 years, 6 months agosobrinho
4 years, 5 months agochamisso
5 years ago