473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Before delete triggers


Hi

If one or mode records get deleted from t1 (see below), I'd like
delete all the corresponding records from t2. There is no foreign key
relationship between t2 and t1, so cascading delete is not an option.
V8.2 AIX

create table t1
(
x int
);
create table t2
(
y int
);

insert into t1 values (2);
insert into t2 values (2);
Can this be accomplished using before delete trigger:

create trigger some_del
no cascade before delete on t1
referencing old as old_t for each row
delete from t2 where y= old_t.x
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0696N The definition of trigger "AAA.some_del " includes an invalid
use
of correlation name or transition table name "old". Reason code="1".
LINE
NUMBER=3. SQLSTATE=42898
Thanks

Nov 12 '05 #1
3 8368
un*****@yahoo.com wrote:
Hi

If one or mode records get deleted from t1 (see below), I'd like
delete all the corresponding records from t2. There is no foreign key
relationship between t2 and t1, so cascading delete is not an option.
V8.2 AIX

create table t1
(
x int
);
create table t2
(
y int
);

insert into t1 values (2);
insert into t2 values (2);
Can this be accomplished using before delete trigger:

create trigger some_del
no cascade before delete on t1
referencing old as old_t for each row
delete from t2 where y= old_t.x
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0696N The definition of trigger "AAA.some_del " includes an invalid
use
of correlation name or transition table name "old". Reason code="1".
LINE
NUMBER=3. SQLSTATE=42898
Thanks

Use an AFTER DELETE trigger.

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
Thanks. The 3rd party software requires that this be a before delete
trigger - don't know why. I did mention after delete trigger to them.
Serge Rielau wrote:
un*****@yahoo.com wrote:
Hi

If one or mode records get deleted from t1 (see below), I'd like
delete all the corresponding records from t2. There is no foreign key relationship between t2 and t1, so cascading delete is not an option. V8.2 AIX

create table t1
(
x int
);
create table t2
(
y int
);

insert into t1 values (2);
insert into t2 values (2);
Can this be accomplished using before delete trigger:

create trigger some_del
no cascade before delete on t1
referencing old as old_t for each row
delete from t2 where y= old_t.x
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0696N The definition of trigger "AAA.some_del " includes an invalid use
of correlation name or transition table name "old". Reason code="1". LINE
NUMBER=3. SQLSTATE=42898
Thanks

Use an AFTER DELETE trigger.

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab


Nov 12 '05 #3
un*****@yahoo.com wrote:
Thanks. The 3rd party software requires that this be a before delete
trigger - don't know why. I did mention after delete trigger to them.
Serge Rielau wrote:
un*****@yahoo.com wrote:
Hi

If one or mode records get deleted from t1 (see below), I'd like
delete all the corresponding records from t2. There is no foreign
key
relationship between t2 and t1, so cascading delete is not an
option.
V8.2 AIX

create table t1
(
x int
);
create table t2
(
y int
);

insert into t1 values (2);
insert into t2 values (2);
Can this be accomplished using before delete trigger:

create trigger some_del
no cascade before delete on t1
referencing old as old_t for each row
delete from t2 where y= old_t.x
DB21034E The command was processed as an SQL statement because it
was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0696N The definition of trigger "AAA.some_del " includes an
invalid
use
of correlation name or transition table name "old". Reason
code="1".
LINE
NUMBER=3. SQLSTATE=42898
Thanks


Use an AFTER DELETE trigger.

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab


*sigh*There are good semantic reasons why the SQL Standard prohibits
updates in before triggers....
Anyway. Ask the vendor whether they are aware of the "ISV enablement
team" of IBM. Porting help can be arranged.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Merlin | last post by:
Hello all! I'll make it short and sweet... I have a database, it looks something like this: id data --- ------------------------- 0 Some Data 1...
1
by: Shock | last post by:
Hi everybody, I just wrote my first two triggers and from the minimal amount of testing I have done, they work! However, I was hoping I could get some feedback from those of you more...
7
by: Aidan Whitehall | last post by:
Have gone through BOL and Google, but can't find the answer... please help with a simple Q. I'm trying to create a simple cascade delete trigger in SQL Server 7 where deleting "parent" records in...
17
by: serge | last post by:
How can i delete all user stored procedures and all table triggers very fast in a single database? Thank you
2
by: ecastillo | last post by:
i'm in a bit of a bind at work. if anyone could help, i'd greatly appreciate it. i have a web app connecting to a sql server using sql server authentication. let's say, for example, my...
1
by: Jon | last post by:
Hi all! Are there any other way than using rights or Triggers to prevent a DELETE or an UPDATE on a specific column. The "problem" with rights is that they dont apply to all DB-users The...
2
by: Jack | last post by:
We are have a question about the no cascade option on before triggers. The description stays that no other triggers will be fired by the changes of a before trigger. One of our developers is...
8
by: candide_sh | last post by:
hello, 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....
1
by: ChrisC | last post by:
Hello, I am attempting to create a trigger to keep track of changes to a table, mainly about specific changes to the data in the table. I had hoped that triggers defined as for each row would...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.