Question: Given CREATE TABLE C _ WORKER ( WID CHAR ( 3 ) PRIMARY KEY, WName VARCHAR 2 ( 1 2 ) , WSalary NUMBER (

Given CREATE TABLE C_WORKER
(
WID CHAR(3) PRIMARY KEY,
WName VARCHAR2(12),
WSalary NUMBER(7,2)
); CREATE TABLE TAXVALUES
(
MaxAmount NUMBER(7,2),
TaxRate NUMBER(3,2)
); CREATE TABLE T_AUDIT
(
WID CHAR(3) REFERENCES C_WORKER(WID),
OLD_Sal NUMBER(7,2),
NEW_Sal NUMBER(7,2),
OLD_Tax NUMBER(7,2),
NEW_Tax NUMBER(7,2),
auditDate DATE DEFAULT SYSDATE,
PRIMARY KEY (WID, auditDATE)
); Write a SQL trigger that will do the following:
The trigger should be named NewTaxByLastFirst. The trigger should be fired after a salary
of a worker changes. It only should run for those workers not withholding the maximum tax before the
update. It should insert all the information requested in the T_AUDIT table for each time the trigger
body runs (once for each row meeting the condition). It should output each workers information on a
single line, showing their ID, old salary, old tax amount, new salary, new tax amount, and difference of
tax withheld. The output should look like this:
114: 450005850495006435585
233: 7200093607920010296936
903: 640008320704009152832
092: 563007319619308050.9731.9

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!