Subject | Re: Alter referenced column |
---|---|
Author | Adam |
Post date | 2005-09-19T22:49:04Z |
Tim,
IMO, Firebrd must either execute a particular DDL statement without
any negative consequence, or give an error message if it is unable to
intelligently do all the internal stuff involved in changing the
fields type.
I am assuming the object in your case is a trigger (AU suffix probably
after update).
The simple way around it is like this.
-- Stop the trigger from referencing the field you want to change
ALTER TRIGGER T_PRODUCTS_RFID_AU2
AS
BEGIN
--
END
^
-- Now change the field definition
alter TABLE T_UPLOADS ALTER COLUMN TS TYPE timestamp
^
-- Now set the trigger back to how it used to be
ALTER TRIGGER T_PRODUCTS_RFID_AU2
AS
BEGIN
-- etc
END
^
By the way, there are many tools that you can get that allow you to
just make the new structure, then give it both the old database and
new structure, and the tool will automagically generate a script
(similar to above) for you. For simple changes, I wouldn't bother, but
where nested views are involved or there are a lot of dependancies it
will save you hours.
Adam
IMO, Firebrd must either execute a particular DDL statement without
any negative consequence, or give an error message if it is unable to
intelligently do all the internal stuff involved in changing the
fields type.
I am assuming the object in your case is a trigger (AU suffix probably
after update).
The simple way around it is like this.
-- Stop the trigger from referencing the field you want to change
ALTER TRIGGER T_PRODUCTS_RFID_AU2
AS
BEGIN
--
END
^
-- Now change the field definition
alter TABLE T_UPLOADS ALTER COLUMN TS TYPE timestamp
^
-- Now set the trigger back to how it used to be
ALTER TRIGGER T_PRODUCTS_RFID_AU2
AS
BEGIN
-- etc
END
^
By the way, there are many tools that you can get that allow you to
just make the new structure, then give it both the old database and
new structure, and the tool will automagically generate a script
(similar to above) for you. For simple changes, I wouldn't bother, but
where nested views are involved or there are a lot of dependancies it
will save you hours.
Adam