Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DB2 : about the CASCADE update/delete

 
Santosh Maskar
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
 
Adeel Ansari
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic