Subject | Re: Check if field exists before adding |
---|---|
Author | Adam Stewart |
Post date | 2003-05-01T15:14:34Z |
Thanks Paul,
How do I then add the field to the table if it doesn't exist, i need
to do this in one script.
Adam.
How do I then add the field to the table if it doesn't exist, i need
to do this in one script.
Adam.
--- In ib-support@yahoogroups.com, Paul Vinkenoog <paul@v...> wrote:
> 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