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
10 11473
Are you sure any records are updated?
Pilgrim.
Are you sure any records are updated?
Pilgrim.
In the table records are getting updated but trigger is still taking Old value.
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.
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 .
try using this 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=:new.col3;
-
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;
-
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.
Yes this is for row level trigger.
@OP, are you looking at Row level trigger updates or statment level? Please confirm?
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
So, the same code works for row level statement, but doesn't work for the statement level trigger?
Pilgrim.
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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 there is
one)
in MS SQL Server. Ditto for a row...
|
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 predictable and
consistent. Since moving to a WinNT/UDB...
|
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 executed when
an error occurs.
Any help would be much...
|
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 questionning/validating the
use of MS Access as front-end. The...
|
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 acSaveRecord is not reflected after the insert so...
|
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, it works
fine!! Since I have a trigger on the...
|
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 has values 1,2,3,... and
i want to update the...
|
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 throughout. In
Access, when I use recordset.AddNew I...
|
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 from bytes.com (formerly thescripts.com).
Ergo, I...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |