Subject Re: [ib-support] Changing field all places
Author Lele Gaifax
>>>>> Paul Vinkenoog l'ha dit:

>> Can I do smething, to change to condition of this field, so
>> that upon change the DB will change it in all places where it
>> is being reference as a foreign key ?

Paul> Yes, when you define a foreign key you can add: ON UPDATE
Paul> CASCADE

Uhm, maybe I'm wrong, but I thing he meant something different. I
understand the question as "how can I modify the kind of a field in a
table, that's a foreign key in other tables?", ie it's not related to
the *content* of the field, but rather to it's definition.

If this is the case, I'd suggest using DOMAINs whereever you can. I'd
start by creating a new domain, say "VARCHAR_ID", equivalent to the
current declaration of your primary key

CREATE DOMAIN varchar_id AS varchar(20)

then I'd proceed by modifying every field in each table that refers to
that PK, ie

ALTER TABLE blabla ALTER COLUMN field TYPE varchar_id

or something similar (I do not have manuals at hand).

From that point, just modifying your new domain will propagate the
effect to all affected fields!

hth,
ciao, lele.
--
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
email: lele@... | -- Fortunato Depero, 1929.