• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

DB2 : about the CASCADE update/delete

 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am not sure whether this is the right fourm to post this type question. please excuse me.

while runnig this sql on db2control center i am getting
sqlcode : -104

sqlstate : 42601

how to set the casecade delete and update on sinle command


CREATE TABLE TEST_CD (
ORDER_DATE TIMESTAMP NOT NULL,
ORDER_ID VARCHAR(16) NOT NULL ,
STORE_ID INT NOT NULL,
CUSTOMER_ID INT NOT NULL,
SHIP_METHOD VARCHAR(8) NOT NULL,
TOTAL_ORDER_AMOUNT NUMERIC(7,2) NOT NULL,
CONSTRAINT pk_ocd PRIMARY KEY (STORE_ID, ORDER_ID),
CONSTRAINT fk_wlcocd FOREIGN KEY (CUSTOMER_ID) REFERENCES DB2ADMIN.C_CD (CUSTOMER_ID) ON DELETE CASCADE ON UPDATE CASCADE );

Thanks
Santosh
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this.

CREATE TABLE TEST_CD (
ORDER_DATE TIMESTAMP NOT NULL,
ORDER_ID VARCHAR(16) NOT NULL ,
STORE_ID INT NOT NULL,
CUSTOMER_ID INT NOT NULL,
SHIP_METHOD VARCHAR(8) NOT NULL,
TOTAL_ORDER_AMOUNT NUMERIC(7,2) NOT NULL,
CONSTRAINT pk_ocd PRIMARY KEY (STORE_ID, ORDER_ID),
CONSTRAINT fk_wlcocd FOREIGN KEY (CUSTOMER_ID) REFERENCES DB2ADMIN.C_CD (DB2ADMIN.C_CD.CUSTOMER_ID)
ON DELETE CASCADE ON UPDATE CASCADE);
 
Santosh Maskar
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SQL0104N An unexpected token

not working
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it working without any of the cascade or one of the cascade?
Try on delete cascade alone, and then try on update cascade alone. Hope you will get some light.
 
Can't .... do .... plaid .... So I did this tiny ad instead:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!