Subject | Re: [ib-support] Check if field exists before adding |
---|---|
Author | Paul Vinkenoog |
Post date | 2003-05-01T15:07:33Z |
Hello Adam,
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
> I need to update several versions of a database to the same version,I use this SQL:
> 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?
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