473,416 Members | 1,564 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,416 software developers and data experts.

Access SQL Delete problem

Hi all,

I am trying to delete a subset of records (identified using my
InsertRemovePairs query) from a table names TradesDone.

When I execute the nested SELECT on its own it returns the correct
records. When I execute is nested in the DELETE it tries to delete
everything in my database....

What have I missed??

DELETE TradesDone.*
FROM TradesDone
WHERE EXISTS (
SELECT TradesDone.*
FROM InsertRemovePairs, TradesDone
WHERE InsertRemovePairs.TradeID = TradesDone.TradeID
AND InsertRemovePairs.AggressorBrokerID = TradesDone.AggressorBrokerID
AND InsertRemovePairs.Action = TradesDone.Action);

(Access 2000, Win NT)

Many thanks,

Alan

Aug 9 '06 #1
7 7167
al*********@hotmail.co.uk wrote in news:1155133897.152618.77180
@m73g2000cwd.googlegroups.com:
Hi all,

I am trying to delete a subset of records (identified using my
InsertRemovePairs query) from a table names TradesDone.

When I execute the nested SELECT on its own it returns the correct
records. When I execute is nested in the DELETE it tries to delete
everything in my database....

What have I missed??

DELETE TradesDone.*
FROM TradesDone
WHERE EXISTS (
SELECT TradesDone.*
FROM InsertRemovePairs, TradesDone
WHERE InsertRemovePairs.TradeID = TradesDone.TradeID
AND InsertRemovePairs.AggressorBrokerID = TradesDone.AggressorBrokerID
AND InsertRemovePairs.Action = TradesDone.Action);
I understand that "IN" and "EXIST" operators have become the new standard
in place of the more traditional JOINS, but I like my Joins and in many
cases I believe they are far more efficient and safe, if more difficult to
create.

Air (=untested) SQL from me would look something like

"DELETE td.* FROM TradesDone td " _
& "INNER JOIN InsertRemovePairs irp " _
& "ON td.TradeID = irp.TradeID " _
& "AND td.AggressorBrokerID = irp.AggressorBrokerID " _
& "AND td.Action = irp.Action

--
Lyle Fairfield
Aug 9 '06 #2
Lyle,

thanks for the inpu, unfortunately this return the error:

"Could not delete from specified tables"

The database is not read only.
I am the only person with the database open.
I do have permission to modify the database.

Any ideas on why this doesn't work??

A
Lyle Fairfield wrote:
al*********@hotmail.co.uk wrote in news:1155133897.152618.77180
@m73g2000cwd.googlegroups.com:
Hi all,

I am trying to delete a subset of records (identified using my
InsertRemovePairs query) from a table names TradesDone.

When I execute the nested SELECT on its own it returns the correct
records. When I execute is nested in the DELETE it tries to delete
everything in my database....

What have I missed??

DELETE TradesDone.*
FROM TradesDone
WHERE EXISTS (
SELECT TradesDone.*
FROM InsertRemovePairs, TradesDone
WHERE InsertRemovePairs.TradeID = TradesDone.TradeID
AND InsertRemovePairs.AggressorBrokerID = TradesDone.AggressorBrokerID
AND InsertRemovePairs.Action = TradesDone.Action);

I understand that "IN" and "EXIST" operators have become the new standard
in place of the more traditional JOINS, but I like my Joins and in many
cases I believe they are far more efficient and safe, if more difficult to
create.

Air (=untested) SQL from me would look something like

"DELETE td.* FROM TradesDone td " _
& "INNER JOIN InsertRemovePairs irp " _
& "ON td.TradeID = irp.TradeID " _
& "AND td.AggressorBrokerID = irp.AggressorBrokerID " _
& "AND td.Action = irp.Action

--
Lyle Fairfield
Aug 9 '06 #3
al*********@hotmail.co.uk wrote in
news:11********************@h48g2000cwc.googlegrou ps.com:
Lyle,

thanks for the inpu, unfortunately this return the error:

"Could not delete from specified tables"

The database is not read only.
I am the only person with the database open.
I do have permission to modify the database.

Any ideas on why this doesn't work??
Sometimes when we cannot delete it is because we have relationships which
are required to be maintained. A child record exists and this referential
integrity requires that its parent remains alive and well and living in the
table from which we are trying to delete it.

TTBOMK this will affect only specific records and not entire deletes.

So, perhaps I have some wrong syntax. Without the tables, I'm sure you
understand it's very difficult to investigate further.

--
Lyle Fairfield
Aug 9 '06 #4
I can confirm that referential integrity is not a problem as the
database contains only one table.

Do you know of any good tutorials/API specifications for Access' SQL,
it doesn't seem to work the same way as standard SQL....

Cheers,

Alan
Lyle Fairfield wrote:
al*********@hotmail.co.uk wrote in
news:11********************@h48g2000cwc.googlegrou ps.com:
Lyle,

thanks for the inpu, unfortunately this return the error:

"Could not delete from specified tables"

The database is not read only.
I am the only person with the database open.
I do have permission to modify the database.

Any ideas on why this doesn't work??

Sometimes when we cannot delete it is because we have relationships which
are required to be maintained. A child record exists and this referential
integrity requires that its parent remains alive and well and living in the
table from which we are trying to delete it.

TTBOMK this will affect only specific records and not entire deletes.

So, perhaps I have some wrong syntax. Without the tables, I'm sure you
understand it's very difficult to investigate further.

--
Lyle Fairfield
Aug 9 '06 #5
al*********@hotmail.co.uk wrote in
news:11**********************@i3g2000cwc.googlegro ups.com:
I can confirm that referential integrity is not a problem as the
database contains only one table.

Do you know of any good tutorials/API specifications for Access' SQL,
it doesn't seem to work the same way as standard SQL....

Cheers,

Alan
Lyle Fairfield wrote:
>al*********@hotmail.co.uk wrote in
news:11********************@h48g2000cwc.googlegro ups.com:
Lyle,

thanks for the inpu, unfortunately this return the error:

"Could not delete from specified tables"

The database is not read only.
I am the only person with the database open.
I do have permission to modify the database.

Any ideas on why this doesn't work??

Sometimes when we cannot delete it is because we have relationships
which are required to be maintained. A child record exists and this
referential integrity requires that its parent remains alive and well
and living in the table from which we are trying to delete it.

TTBOMK this will affect only specific records and not entire deletes.

So, perhaps I have some wrong syntax. Without the tables, I'm sure
you understand it's very difficult to investigate further.

--
Lyle Fairfield
Perhaps you could tell us the sql of the InsertRemovePairs Query.

--
Lyle Fairfield
Aug 9 '06 #6
Morning,

I think I can also rule out the SQL for InsertRemovePairs as I copied
the results of this query to a new table (called irp, with no
relationthips to the other table) and used the query...

DELETE td.*
FROM TradesDone AS td INNER JOIN irp ON (td.Action = irp.Action) AND
(td.AggressorBrokerID = irp.AggressorBrokerID) AND (td.TradeID =
irp.TradeID);

which returned the same error:

'could not delete from specified table.'

are there any special properties the table or fields must have for the
DELETE to work?? Changing DELETE to SELECT returns exactly what I am
trying to remove....

thanks,

A

Lyle Fairfield wrote:
al*********@hotmail.co.uk wrote in
news:11**********************@i3g2000cwc.googlegro ups.com:
I can confirm that referential integrity is not a problem as the
database contains only one table.

Do you know of any good tutorials/API specifications for Access' SQL,
it doesn't seem to work the same way as standard SQL....

Cheers,

Alan
Lyle Fairfield wrote:
al*********@hotmail.co.uk wrote in
news:11********************@h48g2000cwc.googlegrou ps.com:

Lyle,

thanks for the inpu, unfortunately this return the error:

"Could not delete from specified tables"

The database is not read only.
I am the only person with the database open.
I do have permission to modify the database.

Any ideas on why this doesn't work??

Sometimes when we cannot delete it is because we have relationships
which are required to be maintained. A child record exists and this
referential integrity requires that its parent remains alive and well
and living in the table from which we are trying to delete it.

TTBOMK this will affect only specific records and not entire deletes.

So, perhaps I have some wrong syntax. Without the tables, I'm sure
you understand it's very difficult to investigate further.

--
Lyle Fairfield

Perhaps you could tell us the sql of the InsertRemovePairs Query.

--
Lyle Fairfield
Aug 10 '06 #7
al*********@hotmail.co.uk wrote in news:1155199771.202686.302780
@i42g2000cwa.googlegroups.com:
Morning,

I think I can also rule out the SQL for InsertRemovePairs as I copied
the results of this query to a new table (called irp, with no
relationthips to the other table) and used the query...

DELETE td.*
FROM TradesDone AS td INNER JOIN irp ON (td.Action = irp.Action) AND
(td.AggressorBrokerID = irp.AggressorBrokerID) AND (td.TradeID =
irp.TradeID);

which returned the same error:

'could not delete from specified table.'
I am sorry this has gone so wrong and that I have not been more alert.
Would you, please, try?

DELETE DISTINCTROW td.*
FROM TradesDone AS td INNER JOIN irp ON (td.Action = irp.Action) AND
(td.AggressorBrokerID = irp.AggressorBrokerID) AND (td.TradeID =
irp.TradeID);

--
Lyle Fairfield
Aug 10 '06 #8

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

Similar topics

6
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...
49
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...
12
by: John | last post by:
Hi When I try to run access 97 I get the message 'Microsoft Access couldn't find file c:\windows\system32\system.mdw'. When I try to create the system.mdw file using workgroup administrator, I...
4
by: Saso Zagoranski | last post by:
Hi! Here is what I'm trying to do: I have created a UserControl named PictureView. It holds all the images in one directory in the Bitmap images variable. The selected image is displayed in...
10
by: Eric E | last post by:
Hi all, I am using an Access client linked to a PG 7.4 server via ODBC. I have a stored proc on the server that inserts rows into a table.particular table, accomplished via an INSERT within the...
12
by: dennist685 | last post by:
Can't edit, delete or add row in an Access database in a website 2003 When I implement a walkthrough using Northwind I have no trouble doing this. Also, in a windowsforms project I have no...
13
by: royaltiger | last post by:
I am trying to copy the inventory database in Building Access Applications by John L Viescas but when i try to run the database i get an error in the orders form when i click on the allocate...
1
by: sphinney | last post by:
All, I'm not sure how to adequately explain my problem in two sentences or less, so at the risk of providing TMI, here's the condensed verion. I have developed an Access 2002 database file that...
6
by: scott.tang | last post by:
I'm experiencing a very strange problem. My application is MS Access front-end and MS SQL server back-end database. I have a SQL statement that deletes records from a table after an export...
9
by: O | last post by:
I need to do some lookups and updates on some legacy Access 2.0 files (they've from another vendor and I'm not in a position to update them). I was successful using VB6, but I've moved on to VS...
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: 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
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
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...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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
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...

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.