473,563 Members | 2,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cascade delete

I have 3 tables and they are all a one-one relationship. The tables
are in oracle with Access as the front end. If user deletes a record
from Table1, how do I programmaticall y delete the associated record
from Table2 and Table 3?

thankx,

Mitchell,
Nov 13 '05 #1
2 2727
On 1 Jul 2004 19:40:30 -0700, mi******@boh.co m (Mitchell Thomas)
wrote:

Ask your Oracle DBA. She can probaly help you put a trigger in place
to perform the cascade delete at the database level. Or perhaps Oracle
has a declarative way to express cascade delete as well - I'm no
expert in that.
Doing this in Access is less desirable. If you decide to go that way
anyway, at least do it in a transaction:
pseudocode:
on error goto errorhandler
begintrans
delete * from table1 where primarykeyvalue =X
delete * from table2 where foreignkeyvalue =X
delete * from table3 where foreignkeyvalue =X
committrans
exit sub
errorhandler:
rollback
end sub

-Tom.

I have 3 tables and they are all a one-one relationship. The tables
are in oracle with Access as the front end. If user deletes a record
from Table1, how do I programmaticall y delete the associated record
from Table2 and Table 3?

thankx,

Mitchell,


Nov 13 '05 #2
Tom van Stiphout wrote:
On 1 Jul 2004 19:40:30 -0700, mi******@boh.co m (Mitchell Thomas)
wrote:

Ask your Oracle DBA. She can probaly help you put a trigger in place
to perform the cascade delete at the database level. Or perhaps Oracle
has a declarative way to express cascade delete as well - I'm no
expert in that.
Doing this in Access is less desirable. If you decide to go that way
anyway, at least do it in a transaction:
pseudocode:
on error goto errorhandler
begintrans
delete * from table1 where primarykeyvalue =X
delete * from table2 where foreignkeyvalue =X
delete * from table3 where foreignkeyvalue =X
committrans
exit sub
errorhandler:
rollback
end sub


It may be more complex than that, if there is RI on the back-end (I'd be
suprised if there wasn't) then you'd need to delete in the reverse
order. The example given is a 1:1 relationship so we know the value to
delete from table3 but if it were 1:n relationships we don't immediately
know the pk of table3 so table2 would need to be looped.

--
Error reading sig - A)bort R)etry I)nfluence with large hammer
Nov 13 '05 #3

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

Similar topics

0
5892
by: Fraser Hanson | last post by:
Hello, I have a table which has a foreign key relationship with itself. I want and expect my updates to cascade (deletes definitely cascade as expected) but instead I just get error 1217: foriegn key error. I have written example code to use in reproducing the problem: # Create the table
1
8869
by: Andrew DeFaria | last post by:
I created the following .sql file to demonstrate a problem I'm having. According to the manual: If |ON DELETE CASCADE| is specified, and a row in the parent table is deleted, then InnoDB automatically deletes also all those rows in the child table whose foreign key values are equal to the referenced key value in the parent row. However:
0
18803
by: Rob Panosh | last post by:
Hello, If I have table the following table structure: Table Customer ( CustomerId Numeric(10,0) Not Null, ... ) Table CustomerOrders ( CustomerOrderId As Numeric(10,0) Not Null, CustomerId Numeric(10,0) Not Null, CustomerRefId Numeric (10,0) Not Null, ... )
3
8219
by: SuryaPrakash Patel via SQLMonster.com | last post by:
Hello, There are three tables: OS-GroupOFCompanies (Table1) GoC_GroupOFCompaniesID (PK) OS-Organization (Table 2) Org_OrganizationID (PK)
2
11508
by: P.B. via SQLMonster.com | last post by:
I cannot execute my sql to create a table with ON DELETE CASCADE option. Here is my sql: CREATE TABLE Employees (Name Text(10) not null, Age number, CONSTRAINT pkEmployees PRIMARY KEY (Name)); <--- This is ok! CREATE TABLE CanTake (Name Text(10) not null, Make Text(10) not null, CONSTRAINT pkCanTake PRIMARY KEY (Name, Make),
3
3885
by: Tim Marshall | last post by:
HI all, Access 2003, Jet back end. Rather than annoy my users in a particular app by having relationships with enforced relational integrity refuse to delete a record with related records, I'm using cascade delete. When I use a continuous form and a record is deleted, Access provides a warning that there are related records, do you want...
14
5771
by: Karl O. Pinc | last post by:
Hi, Thought perhaps some other eyes than mine can tell if I'm doing something wrong here or if there's a bug somewhere. I've never passed a ROWTYPE varaible to a function but I don't see where the problem is. I keep getting errors like (the first is my debug output): NOTICE: last cycle is: 11 WARNING: Error occurred while executing...
2
3081
by: R.Welz | last post by:
Hello. I want to discuss a problem I have with my database design becourse I feel I cannot decide wheather I am on the right way of doing things. First of all, I am writing a literature and magazine database with web (PHP) and C++ Interface, serving over the web and in a very fast LAN. So my concern is about performance (and aestaetic by...
2
7654
by: nekiv90 | last post by:
Greetings, I have to delete older policies and its related records in other tables. The deletion from the parent table will trigger the deletion of relevant records from about 30 something tables that are defined with DELETE CASCADE. The delete SQL goes like this:
0
1649
by: Cirene | last post by:
Can you assist me with this database problem? I have 4 tables in my db.... Table1 (key: Table1Id) Table2 (key: Table2Id) Table3 (key: Table3Id) Table 4 has these fields: key: Table4Id Table1Id (ties it to Table 1)
0
7659
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7882
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7634
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5481
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5208
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3618
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2079
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.