Home » SQL & PL/SQL » SQL & PL/SQL » SQL%ROWCOUNT USing in INSERT or update trigger (Oracle 10G windows )
|
Re: SQL%ROWCOUNT USing in INSERT or update trigger [message #574387 is a reply to message #574383] |
Wed, 09 January 2013 18:46   |
 |
dariyoosh
Messages: 538 Registered: March 2009 Location: France
|
Senior Member |
|
|
A FOR EACH ROW trigger is fired once for each row affected by the DML, therefore one row processed at a time! As a result v_rows > 1 will never be true within your trigger.
In addition, DBMS_OUTPUT.PUT_LINE inside the trigger is useless as the trigger is executed at the server side, you will need to update a log table or a log file.
What do you want to do exactly? particularly if we are talking about this problem within a multi-user environment?
Regards,
Dariyoosh
[Updated on: Wed, 09 January 2013 18:52] Report message to a moderator
|
|
|
Re: SQL%ROWCOUNT USing in INSERT or update trigger [message #574406 is a reply to message #574387] |
Thu, 10 January 2013 01:32  |
 |
Michel Cadot
Messages: 68758 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Quote:s a result v_rows > 1 will never be true within your trigger.
As well as v_rowsz=0, as if there is no rows to insert or update the trigger will not fire.
Quote:In addition, DBMS_OUTPUT.PUT_LINE inside the trigger is useless as the trigger is executed at the server side,
Although it is right the trigger execute in server side (as ALL SQL or PL/SQL code), it is not useless, the result is displayed by the client (if it supports and has activated the feature).
In the end, it is a very BAD practice to use dbms_output but for debugging purpose.
@skumari
Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" or "Preview Quick Reply" button to verify.
Also always post your Oracle version, with 4 decimals.
If you want to insert or update one row at a time (why? I don't see any reason for this but to have bad performances), then test %ROWCOUNT at application level.
Regards
Michel
|
|
|
Goto Forum:
Current Time: Thu Jun 12 14:23:19 CDT 2025
|