Subject Re: FbException while doing "ALTER TABLE" on a recently open connection.
Author Adam
--- In firebird-support@yahoogroups.com, "asakin312" <asakin@...> wrote:
>
> Hi,
> I am connecting to a 12MB Database file using the .NET provider for
> firebird.
> When trying to run an ALTER TABLE command on the database right
> after the connection is opened, I get the following exception:
> "An exception was thrown when executing command: ALTER TABLE
> ScreenShots
> ADD CONSTRAINT PK_Screenshots PRIMARY KEY (ImageID),
> ADD CONSTRAINT FK_ImageVariantID FOREIGN KEY (VariantID) REFERENCES
> Variants(engineid) ON DELETE CASCADE
> Batch execution aborted
> The returned message was: unsuccessful metadata update
> object VARIANTS is in use"
>
> If I wait about 10 seconds between the connection and running the
> command, no exception is thrown.
>
> Anyone can help?

You can not declare a foreign key to Variants if another transaction
has done something with that table. My guess is that 10 seconds later,
that other transactions had all committed or rolled back.

You need exclusive access for DDL changes. (not for all, but it is
much less headache if you do)

Adam