Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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.
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic