![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I googled around some time but I found no solution for this issue (SS2000). I have a table tblB which has to be filled whenever in table tblA records are inserted, updated or deleted. So I created one trigger which works fine for inserts and updates and fills my tblB. tblB is filled with other fields which I get from a view vwC. This view vwC is based on a key field used in tblA. The issue is about this view. When in tblA a record is deleted, the corresponding record in vwC does not exist and I can't fill tblB. I tried around with INSTEAD OF -Trigger and got error message because tblA has RI cascades so this is not possible. A temp table could be the right way? Can you show me an example? |
#3
| |||
| |||
|
|
(candide... (AT) yahoo (DOT) de) writes: I googled around some time but I found no solution for this issue (SS2000). |
#4
| |||
| |||
|
|
I met a SS-Professional yesterday and he told me to use stored procedures. As there was no time to waste I did so and it seems to work. Still wondering there's no Before-Trigger event in SS2005. maybe in SS2008? |
#5
| |||
| |||
|
|
(candide_sh (AT) yahoo (DOT) de) writes: I met a SS-Professional yesterday and he told me to use stored procedures. As there was no time to waste I did so and it seems to work. Still wondering there's no Before-Trigger event in SS2005. maybe in SS2008? I have not heard anything on that. I fond a request for BEFORE TRIGGERS on https://connect.microsoft.com/SQLSer...dbackID=285655 that you can vote for if you like. |
#6
| |||
| |||
|
|
Erland Sommarskog wrote: (candide... (AT) yahoo (DOT) de) writes: I met a SS-Professional yesterday and he told me to use stored procedures. As there was no time to waste I did so and it seems to work. Still wondering there's no Before-Trigger event in SS2005. maybe in SS2008? I have not heard anything on that. I fond a request for BEFORE TRIGGERS on https://connect.microsoft.com/SQLSer...edback.aspx?Fe... that you can vote for if you like. SQL Server is now the only major commercial database without them. Given how easy they would be to implement, Oracle had them in 1989, does anyone know why the delay? -- Daniel A. Morgan University of Washington damor...@x.washington.edu (replace x with u to respond) |
#7
| |||
| |||
|
|
On Jul 20, 5:49 pm, DA Morgan <damor... (AT) psoug (DOT) org> wrote: Erland Sommarskog wrote: (candide... (AT) yahoo (DOT) de) writes: I met a SS-Professional yesterday and he told me to use stored procedures. As there was no time to waste I did so and it seems to work. Still wondering there's no Before-Trigger event in SS2005. maybe in SS2008? I have not heard anything on that. I fond a request for BEFORE TRIGGERS on https://connect.microsoft.com/SQLSer...edback.aspx?Fe... that you can vote for if you like. SQL Server is now the only major commercial database without them. Given how easy they would be to implement, Oracle had them in 1989, does anyone know why the delay? -- Daniel A. Morgan University of Washington damor...@x.washington.edu (replace x with u to respond) Agreed, but on the other hand Oracle fires triggers once per row, not once per statement - and that can really drag performance. No RDBMS is perfect... |
#8
| |||
| |||
|
|
Alex Kuznetsov wrote: On Jul 20, 5:49 pm, DA Morgan <damor... (AT) psoug (DOT) org> wrote: Erland Sommarskog wrote: (candide... (AT) yahoo (DOT) de) writes: I met a SS-Professional yesterday and he told me to use stored procedures. As there was no time to waste I did so and it seems to work. Still wondering there's no Before-Trigger event in SS2005. maybe in SS2008? I have not heard anything on that. I fond a request for BEFORE TRIGGERS on https://connect.microsoft.com/SQLSer...edback.aspx?Fe... that you can vote for if you like. SQL Server is now the only major commercial database without them. Given how easy they would be to implement, Oracle had them in 1989, does anyone know why the delay? -- Daniel A. Morgan University of Washington damor...@x.washington.edu (replace x with u to respond) Agreed, but on the other hand Oracle fires triggers once per row, not once per statement - and that can really drag performance. No RDBMS is perfect... On the other hand you are incorrect. Oracle gives developers the choice of firing one per row or once per statement and always has. In fact the default is once per statement. But no none is perfect. If they were we would all be unemployed. Here are some samples so you can tell the difference: CREATE OR REPLACE TRIGGER statement_level BEFORE UPDATE ON orders DECLARE vMsg VARCHAR2(30) := 'Statement Level Trigger Fired'; BEGIN dbms_output.put_line(vMsg); END statement_level; / CREATE OR REPLACE TRIGGER row_level BEFORE UPDATE FOR EACH ROW <---- if this isn't here it is statement level ON orders DECLARE vMsg VARCHAR2(30) := 'Row Level Trigger Fired'; BEGIN dbms_output.put_line(vMsg); END row_level; / |
#9
| |||
| |||
|
|
Alex Kuznetsov wrote: On Jul 20, 5:49 pm, DA Morgan <damor... (AT) psoug (DOT) org> wrote: Erland Sommarskog wrote: (candide... (AT) yahoo (DOT) de) writes: I met a SS-Professional yesterday and he told me to use stored procedures. As there was no time to waste I did so and it seems to work. Still wondering there's no Before-Trigger event in SS2005. maybe in SS2008? I have not heard anything on that. I fond a request for BEFORE TRIGGERS on https://connect.microsoft.com/SQLSer...edback.aspx?Fe... that you can vote for if you like. SQL Server is now the only major commercial database without them. Given how easy they would be to implement, Oracle had them in 1989, does anyone know why the delay? -- Daniel A. Morgan University of Washington damor...@x.washington.edu (replace x with u to respond) Agreed, but on the other hand Oracle fires triggers once per row, not once per statement - and that can really drag performance. No RDBMS is perfect... On the other hand you are incorrect. Oracle gives developers the choice of firing one per row or once per statement and always has. In fact the default is once per statement. But no none is perfect. If they were we would all be unemployed. Here are some samples so you can tell the difference: CREATE OR REPLACE TRIGGER statement_level BEFORE UPDATE ON orders DECLARE vMsg VARCHAR2(30) := 'Statement Level Trigger Fired'; BEGIN dbms_output.put_line(vMsg); END statement_level; / CREATE OR REPLACE TRIGGER statement_level BEFORE UPDATE FOR EACH ROW <---- if this isn't here it is statement level ON orders DECLARE vMsg VARCHAR2(30) := 'Row Level Trigger Fired'; BEGIN dbms_output.put_line(vMsg); END statement_level; / I beg to differ. A trigger that fires only for the first row it runs |
#10
| |||
| |||
|
|
DA Morgan wrote: Alex Kuznetsov wrote: On Jul 20, 5:49 pm, DA Morgan <damor... (AT) psoug (DOT) org> wrote: Erland Sommarskog wrote: (candide... (AT) yahoo (DOT) de) writes: I met a SS-Professional yesterday and he told me to use stored procedures. As there was no time to waste I did so and it seems to work. Still wondering there's no Before-Trigger event in SS2005. maybe in SS2008? I have not heard anything on that. I fond a request for BEFORE TRIGGERS on https://connect.microsoft.com/SQLSer...edback.aspx?Fe... that you can vote for if you like. SQL Server is now the only major commercial database without them. Given how easy they would be to implement, Oracle had them in 1989, does anyone know why the delay? -- Daniel A. Morgan University of Washington damor...@x.washington.edu (replace x with u to respond) Agreed, but on the other hand Oracle fires triggers once per row, not once per statement - and that can really drag performance. No RDBMS is perfect... On the other hand you are incorrect. Oracle gives developers the choice of firing one per row or once per statement and always has. In fact the default is once per statement. But no none is perfect. If they were we would all be unemployed. Here are some samples so you can tell the difference: CREATE OR REPLACE TRIGGER statement_level BEFORE UPDATE ON orders DECLARE vMsg VARCHAR2(30) := 'Statement Level Trigger Fired'; BEGIN dbms_output.put_line(vMsg); END statement_level; / CREATE OR REPLACE TRIGGER statement_level BEFORE UPDATE FOR EACH ROW <---- if this isn't here it is statement level ON orders DECLARE vMsg VARCHAR2(30) := 'Row Level Trigger Fired'; BEGIN dbms_output.put_line(vMsg); END statement_level; / I beg to differ. A trigger that fires only for the first row it runs into is NOT a statement trigger. Statement triggers allow access to the NEW TABLE (aka INSERTED) and OLD TABLE (DELETED). Also a statement trigger fires even if no row is modified. I'm unsure that is the case in Oracle. Does Oracle still have issues with "mutating table conflicts" or is that finally fixed in 11g? I'd be careful with throwing stones in the glass house. Cheers Serge |
![]() |
| Thread Tools | |
| Display Modes | |
| |