wood burning stoves 2.0*
The moose likes JDBC and the fly likes DB2 : about the CASCADE update/delete Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "DB2 : about the CASCADE update/delete" Watch "DB2 : about the CASCADE update/delete" New topic
Author

DB2 : about the CASCADE update/delete

Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
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

Joined: Aug 15, 2004
Posts: 2874
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

Joined: Jul 02, 2003
Posts: 226
SQL0104N An unexpected token

not working
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
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.
 
 
subject: DB2 : about the CASCADE update/delete