Subject Re: [ib-support] Check if field exists before adding
Author Paul Vinkenoog
Hello Adam,

> I need to update several versions of a database to the same version,
> I would like to do this by sending a SQL script to the customers.
> however to do this I first need to see if a field is present before
> I add it. Is this possible and if so how?

I use this SQL:

SELECT COUNT (RDB$FIELD_NAME)
FROM RDB$RELATION_FIELDS
WHERE RDB$FIELD_NAME = MYFIELDNAME

If the fieldname is not unique, add

AND RDB$RELATION_NAME = MYTABLENAME


This returns 1 if the field exists, 0 if not.

You can also remove COUNT( ) from the SQL. Then you get the field name
if it's there, NULL if it isn't.


Greetings,
Paul Vinkenoog