Adding Constraints with Cascade

C

CurryMan

I'm trying to add foreign key constraints to a table and everything
works
except that if I include the CASCADE ON DELETE/UPDATE options I get
errors.
Has any one got any ideas what I need to do or what could be wrong.

Cheers
Glenn


DoCmd.RunSQL "CREATE TABLE COLTBL (COLID COUNTER CONSTRAINT PrimaryKey
PRIMARY KEY, .... )", False

DoCmd.RunSQL "CREATE TABLE MAINTAB (....., COLID long ,.....)",False

DoCmd.RunSQL "ALTER TABLE MAINTAB ADD CONSTRAINT Constr1 FOREIGN KEY
(COLID) REFERENCES COLTBL"
***This works fine without ON UPDATE/DELETE Clause


DoCmd.RunSQL "ALTER TABLE MAINTAB ADD CONSTRAINT Constr1 FOREIGN KEY
(COLID) REFERENCES COLTBL ON UPDATE CASCADE ON DELETE CASCADE"
***But this comes up with and "Error in CONSTRAINT"
 
T

Tim Ferguson

I'm trying to add foreign key constraints to a table and everything
works
except that if I include the CASCADE ON DELETE/UPDATE options I get
errors.

It depends how you are calling the SQL; different versions of jet allow
different clauses.

Try using ADO instead of DAO:

CurrentProject.Connection.Execute ...

HTH

Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top