473,405 Members | 2,287 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,405 software developers and data experts.

DELETE CASCADE - Syntax Error in Constraint Clause (Error 3289)

HH
I try to make a script for generating backend databases. When I try to
make a relationship between a table named 'users' and another table
name 'layouts' an error occurs.

Option 1:
CurrentDB.Execute "ALTER TABLE layouts ADD CONSTRAINT users_layouts
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE"

Option 2:
DoCmd.RunSQL "ALTER TABLE layouts ADD CONSTRAINT users_layouts FOREIGN
KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE"

All environments are set to ANSI 92.

I prefer to use Option 1 which fails, Option 2 doesn't. Could anybody
give an explanation for this?

Jan 11 '07 #1
1 10856
"HH" <ha***********@hwits.nlwrote in message
<11**********************@i39g2000hsf.googlegroups .com>:
I try to make a script for generating backend databases. When I try
to make a relationship between a table named 'users' and another
table name 'layouts' an error occurs.

Option 1:
CurrentDB.Execute "ALTER TABLE layouts ADD CONSTRAINT users_layouts
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE"

Option 2:
DoCmd.RunSQL "ALTER TABLE layouts ADD CONSTRAINT users_layouts
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE"

All environments are set to ANSI 92.

I prefer to use Option 1 which fails, Option 2 doesn't. Could anybody
give an explanation for this?
If you need to use DDL, I think this can only be achieved through ADO
and the OLE DB provider, due to the "ON UPDATE CASCADE". For instance

CurrentProject.Connection.Execute _
"ALTER TABLE layouts ADD CONSTRAINT users_layouts " & _
"FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE"

See for instance
http://msdn2.microsoft.com/en-us/lib...ffice.10).aspx
for more info

--
Roy-Vidar
Jan 11 '07 #2

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

Similar topics

5
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...
0
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,...
2
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)); ...
0
by: Partha | last post by:
Here is the script which generates drop and add fkey constraint This is based on another posting << Erland posted this a short time ago, you should be able to modify it to meet your needs:...
4
by: Jean-Christian Imbeault | last post by:
Currently I have a table defined as such: TAL=# \d internal_keywords Table "public.internal_keywords" Column | Type | Modifiers ---------+---------+----------- keyword | text | not null...
3
by: hilz | last post by:
Hi all I am trying to create a relation between two tables. this is the sql statement in question alter table T1 add constraint relation_T1_to_T2 foreign key (T2_ID) references T2 (ID) on...
14
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...
3
by: bilbo | last post by:
Can anybody help me understand why I get the error "Syntax error in CONSTRAINT clause"? I get it in Access 2003 and Access 2007. Both are clean installs with no add-ins Running this code in...
2
by: manjuns | last post by:
create table A(a1 varchar(10)) create table B(b1 varchar(10), a1 varchar(10) not null) alter table A add primary key(a1) alter table B ADD CONSTRAINT "a_fkey" foreign key (a1) references A (a1)...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.