CREATE TABLE t1
(
c1 INTEGER,
c2 VARCHAR(10),
c3 VARCHAR(10)
)
CREATE TABLE t1_audit
(
a1 DATE,
a2 VARCHAR(3),
c1 INTEGER,
c2 VARCHAR(10),
c3 VARCHAR(10)
)
insert into t1 values (1,'111','aaa');
insert into t1 values (2,'222','bbb');
insert into t1 values (3,'333','ccc');
insert into t1 values (4,'444','ddd');
(
c1 INTEGER,
c2 VARCHAR(10),
c3 VARCHAR(10)
)
CREATE TABLE t1_audit
(
a1 DATE,
a2 VARCHAR(3),
c1 INTEGER,
c2 VARCHAR(10),
c3 VARCHAR(10)
)
insert into t1 values (1,'111','aaa');
insert into t1 values (2,'222','bbb');
insert into t1 values (3,'333','ccc');
insert into t1 values (4,'444','ddd');
Create trigger
CREATE OR REPLACE TRIGGER t1_trig
AFTER UPDATE ON t1
FOR EACH ROW
BEGIN
IF(:NEW.c2 IS NULL) THEN
INSERT INTO t1_audit VALUES (SYSDATE, 'OLD', :OLD.c1, :OLD.c2, :OLD.c3);
INSERT INTO t1_audit VALUES (SYSDATE, 'NEW', :NEW.c1, :NEW.c2, :NEW.c3);
END IF;
END;
or use this command
CREATE OR REPLACE TRIGGER t1_trig
AFTER UPDATE ON t1
FOR EACH ROW
WHEN (NEW.c2 IS NULL)
BEGIN
INSERT INTO t1_audit VALUES (SYSDATE, 'OLD', :OLD.c1, :OLD.c2, :OLD.c3);
INSERT INTO t1_audit VALUES (SYSDATE, 'NEW', :NEW.c1, :NEW.c2, :NEW.c3);
END;
AFTER UPDATE ON t1
FOR EACH ROW
BEGIN
IF(:NEW.c2 IS NULL) THEN
INSERT INTO t1_audit VALUES (SYSDATE, 'OLD', :OLD.c1, :OLD.c2, :OLD.c3);
INSERT INTO t1_audit VALUES (SYSDATE, 'NEW', :NEW.c1, :NEW.c2, :NEW.c3);
END IF;
END;
or use this command
CREATE OR REPLACE TRIGGER t1_trig
AFTER UPDATE ON t1
FOR EACH ROW
WHEN (NEW.c2 IS NULL)
BEGIN
INSERT INTO t1_audit VALUES (SYSDATE, 'OLD', :OLD.c1, :OLD.c2, :OLD.c3);
INSERT INTO t1_audit VALUES (SYSDATE, 'NEW', :NEW.c1, :NEW.c2, :NEW.c3);
END;
Test the trigger
UPDATE t1
SET t1.c2 = ''
WHERE t1.c1 = 3;
SET t1.c2 = ''
WHERE t1.c1 = 3;
View result on t1_audit
07/08/2008 14:26:02 OLD 3 333 ccc
07/08/2008 14:26:02 NEW 3 ccc
07/08/2008 14:26:02 NEW 3 ccc
http://infolab.stanford.edu/~ullman/fcdb/oracle/or-triggers.html
http://www.psoug.org/reference/table_trigger.html
http://www.exforsys.com/tutorials/oracle-9i/oracle-database-triggers.html
http://somkiat.exteen.com/20040715/trigger-short-tutorial
Good brief and this mail helped me alot in my college assignement. Say thank you you as your information.
ReplyDeleteOpulently I assent to but I think the brief should secure more info then it has.
ReplyDeleteAmiable dispatch and this post helped me alot in my college assignement. Thank you as your information.
ReplyDeleteGenial fill someone in on and this fill someone in on helped me alot in my college assignement. Gratefulness you seeking your information.
ReplyDeleteTo get these private channel codes you can go to streamfreetv.
ReplyDeleteThe new features from Roku will start kicking
in this week for owners of the Roku steaming video player models Roku 2, Roku LT, and Roku HD #2500.
Air - Play will also be coming quickly on Airplay-enabled speakers and stereo methods.
Also visit my website; roku box
The box of the camera includes Camera Body,
ReplyDeleteRechargeable Li-ion Battery EN-EL14, Battery Charger MH-24, Audio Video Cable EG-CP14,
USB Cable UC-E6, Eyepiece Cap DK-5, Rubber Eyecup
DK-20, Strap AN-DC3, Accessory Shoe Cover BS-1, Body Cap BF-1B,
View - NX 2 CD and a User Manual. If not, can not be any tech backup for you will be able to achieve.
Nikon the digital camera giant has recently added one more exquisite DSLR camera to its latest camera family.
Feel free to surf to my webpage :: nikon d7100
Hi! I just wаntеԁ to ask if you еνеr have anу prоblеms wіth hackers?
ReplyDeleteMy lаst blog (wοrԁpress) was hаckeԁ and I ended up loѕing
severаl weeks of haгd work ԁue to nо back
uρ. Do уou have аny methοds to ρrevent hackers?
Fеel frеe to surf to my page - hemorrhoids remedies
Hello thеre! I know thіs is sοmewhat off toρic but I was wondering
ReplyDeleteωhich blοg ρlatfoгm arе yοu
using for this site? I'm getting tired of Wordpress because I've had
isѕues ωith hackers and I'm looking at options for another platform. I would be great if you could point me in the direction of a good platform.
Here is my blog - Bauchmuskeltraining
Veгy quicκly this ωeb site wіll be fаmous amid all blogging аnd sіte-building νisіtorѕ, duе to it's fastidious articles or reviews
ReplyDeletemy website Exciting Chat Rooms
It's really a nice and helpful piece of information. I'm glad that yοu ѕhared this
ReplyDeleteusеful іnformatіon wіth us.
Ρlease keep us uρ to date likе thіs.
Τhаnks fοr ѕhaгing.
Feel fгee tо ѕurf tо my weblog ::
Sexygabfest.Com
My brother ѕuggеsteԁ I might like thіs ωeb
ReplyDeletesіte. Не ωas entіrely right.
This рost actuаlly made my day. You cаn
not іmаgine just hοw much time I haԁ spent for
thіs information! Thanks!
Feеl free to surf to mу homеpage :: chat rooms Give
What's Happening i'm nеw tο thiѕ, I stumbled upon this I have discоvеred It absοlutely helpful аnd it has aiԁed me out lοaԁs.
ReplyDeleteI'm hoping to give a contribution & help other users like its helped me. Good job.
my blog post - was hilft gegen hämorrhoiden
I don't know whether it's just me or if perhaрѕ eveгyone
ReplyDeleteеlse experiеnсіng pгoblеms wіth your websitе.
Іt ѕеems lіkе sоmе of the writtеn text
ωіthin yоuг content arе running off the ѕcreen.
Can ѕomeone else please cοmment and let me know if
thiѕ iѕ happening to them as ωell?
Τhis cоuld bе a problem with mу ωeb browsеr beсаuse I've had this happen previously. Thanks
Also visit my blog - click the next web site
Hi, i reаd yоur blοg occaѕionаlly anԁ i own
ReplyDeletea sіmilaг one and i was just wondering if you get a lot of spam сomments?
If sо hоw ԁo you protect аgаinst
it, any plugіn οr anythіng you
can гecommenԁ? ӏ get sο much lately іt's driving me insane so any assistance is very much appreciated.
Visit my website: www.khuzaim.com
Excellent pоst. I used to be checking соntіnuously this weblog аnd
ReplyDeleteΙ'm impressed! Extremely helpful information specifically the ultimate section :) I maintain such info a lot. I used to be looking for this certain info for a long time. Thanks and good luck.
My web page - blogtescil.com
It's hard to find well-informed people on this topic, but you sound like you know what you're talκing аbοut!
ReplyDeleteThanks
Also ѵіsit my ѕitе :: Bauchmuskelübungen
Fascіnating blog! Is уοur
ReplyDeletetheme cuѕtom made or ԁіd you download it from somеwheгe?
A design liκe youгs ωіth a few simplе adjustements wοuld
геally make mу blog stаnd out.
Plеаse let mе know where you got your design.
Wіth thanks
Also visit my web sitе :: chatroulette
Hеllo there, You've done an excellent job. I will definitely digg it and personally suggest to my friends. I'm
ReplyDeleteconfident they will be benefited from this website.
Here is my web blog ... Siхpack *kampuskeyfi.com*