Subject | Altering FK constraint via script |
---|---|
Author | sdbeames |
Post date | 2002-02-25T20:35:50Z |
Hi all,
FB 0.9.4.41/IB_SQL
can I alter a foreign key's constraints within a single script?
It seems I have to disconnect & reconnect before dropping the
constraint, but 'disconnect all' isn't allowed. SYSDBA is sole user.
The following causes an 'object INDEX is in use' error at the 'drop
constraint' statement.
/****************************************/
alter TABLE ITEMSUSED add TEMP INTEGER;
commit;
update ITEMSUSED set TEMP = ITEMNO;
/* have to dis/reconnect here */
alter table ITEMSUSED drop constraint ITEMS_ITEMNO_FK;
commit;
alter table ITEMSUSED add constraint ITEMS_ITEMNO_FK
FOREIGN KEY (ITEMNO) REFERENCES ITEMS
ON UPDATE CASCADE
ON DELETE SET NULL;
commit;
update ITEMSUSED set ITEMNO = TEMP;
alter table ITEMSUSED drop TEMP;
commit;
/****************************************/
Can the above be run in a single script?
Thanks,
Steve
FB 0.9.4.41/IB_SQL
can I alter a foreign key's constraints within a single script?
It seems I have to disconnect & reconnect before dropping the
constraint, but 'disconnect all' isn't allowed. SYSDBA is sole user.
The following causes an 'object INDEX is in use' error at the 'drop
constraint' statement.
/****************************************/
alter TABLE ITEMSUSED add TEMP INTEGER;
commit;
update ITEMSUSED set TEMP = ITEMNO;
/* have to dis/reconnect here */
alter table ITEMSUSED drop constraint ITEMS_ITEMNO_FK;
commit;
alter table ITEMSUSED add constraint ITEMS_ITEMNO_FK
FOREIGN KEY (ITEMNO) REFERENCES ITEMS
ON UPDATE CASCADE
ON DELETE SET NULL;
commit;
update ITEMSUSED set ITEMNO = TEMP;
alter table ITEMSUSED drop TEMP;
commit;
/****************************************/
Can the above be run in a single script?
Thanks,
Steve