472,330 Members | 1,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,330 software developers and data experts.

How to access new value Statement Level Trigger

Hi All,
I want to access new value after upadate in statement level trigger.
But in my query I am getting old values.
Here is the Trigger Code:

CREATE OR REPLACE TRIGGER TEST_TRIGGER
AFTER UPDATE OF col3 on table_gyan
DECLARE
PRAGMA AUTONOMOUS_TRANSACTION;
v_count NUMBER:=0;
v_temp_count NUMBER:=0;
BEGIN
SELECT Count(1) into v_count from table_gyan where col3='Y';
If v_count>0 THEN
SELECT COUNT(1) INTO v_temp_count from TRIGGER_TABLE;
if v_temp_count>0 THEN
UPDATE TRIGGER_TABLE SET ACTION='START';
COMMIT;
else
insert into TRIGGER_TABLE(ACTION) values('START');
commit;
end if;
END IF;
END;

.


Now when ever I am executing this query
update table_gyan set col3='Y'
where col1='3'
and col2='100'
Its not doing anything with TRIGGER_TABLE.


Please help me how to do it.

Regards,
Gyanendar
Oct 29 '08 #1
10 11313
Pilgrim333
127 100+
Are you sure any records are updated?

Pilgrim.
Oct 30 '08 #2
Are you sure any records are updated?

Pilgrim.
In the table records are getting updated but trigger is still taking Old value.
Nov 3 '08 #3
Pilgrim333
127 100+
Ok,

So now you have values in the table where col3 has the value 'Y' Try to update col3 now, and see if the trigger_table is updated.

Pilgrim.
Nov 3 '08 #4
Ok,

So now you have values in the table where col3 has the value 'Y' Try to update col3 now, and see if the trigger_table is updated.

Pilgrim.

No ,its not updating trigger_table values.
If before updation table contains 'Y' than its working .
Nov 3 '08 #5
amitpatel66
2,367 Expert 2GB
try using this code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. CREATE OR REPLACE TRIGGER TEST_TRIGGER
  3. AFTER UPDATE OF col3 on table_gyan
  4. DECLARE
  5. PRAGMA AUTONOMOUS_TRANSACTION;
  6. v_count NUMBER:=0;
  7. v_temp_count NUMBER:=0;
  8. BEGIN
  9. SELECT Count(1) into v_count from table_gyan where col3=:new.col3;
  10. If v_count>0 THEN
  11. SELECT COUNT(1) INTO v_temp_count from TRIGGER_TABLE;
  12. if v_temp_count>0 THEN
  13. UPDATE TRIGGER_TABLE SET ACTION='START';
  14. COMMIT;
  15. else
  16. insert into TRIGGER_TABLE(ACTION) values('START');
  17. commit;
  18. end if;
  19. END IF;
  20. END;
  21.  
Nov 4 '08 #6
Pilgrim333
127 100+
As this is a statement level trigger and firest once every statement, the individual values are not available in the trigger.

But the post of amitpatel66 makes us think, make it a row level trigger and use the code amitpatel66 posted and see if the trigger_table table gets updated.

Pilgrim.
Nov 4 '08 #7
amitpatel66
2,367 Expert 2GB
Yes this is for row level trigger.

@OP, are you looking at Row level trigger updates or statment level? Please confirm?
Nov 4 '08 #8
Yes this is for row level trigger.

@OP, are you looking at Row level trigger updates or statment level? Please confirm?
Yes,
Finally I made it row level trigger and every thing worked fine.

But,if 100 rows of table get updated than ,tigger will get fired for all the 100 rows and does the same work.To avoid this problem ,I was thinking for statement level trigger.

Guy's can we have statement level trigger for this work.

Regards,
Gyanendar
Nov 7 '08 #9
Pilgrim333
127 100+
So, the same code works for row level statement, but doesn't work for the statement level trigger?

Pilgrim.
Nov 7 '08 #10
amitpatel66
2,367 Expert 2GB
Yes,
Finally I made it row level trigger and every thing worked fine.

But,if 100 rows of table get updated than ,tigger will get fired for all the 100 rows and does the same work.To avoid this problem ,I was thinking for statement level trigger.

Guy's can we have statement level trigger for this work.

Regards,
Gyanendar
No you cannot. If you want it to work for all the records then you should have row level trigger
Nov 7 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Allan Hart | last post by:
Hi.. I'd very much appreciate it if someone would tell me how to translate a statement level trigger written in Oracle to its equivalent (if...
14
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are...
7
by: peter.morin | last post by:
Issue: I am inserting an Oracle record containing insert trigger via Access 2002 using the code below. The issue is that the sequence from the...
6
by: Hardy Wang | last post by:
Hi all, I have the following codes, but SCOPE_IDENTITY() just returns NULL to me. If I comment out SCOPE_IDENTITY() line and run @@IDENTITY line,...
4
by: rama | last post by:
Hi, I am a bit troubled with the row-level triggers which PostgreSQL uses when using update table cpmmand. For instance, if the primary key column...
17
by: Rico | last post by:
Hello, I am in the midst of converting an Access back end to SQL Server Express. The front end program (converted to Access 2003) uses DAO...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.