Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Performing database maintenance programmatically
Fri, Feb 23 2007 9:30 AMPermanent Link

"John Taylor"
Question...

I have a series of apps that use the same database and periodically I'll
need to add a new field somewhere, that's where
the problem comes in.   I know exclusive access is needed to add the field
so if the other applications are accessing the
table it can't happen.  I would however like an IsFieldInTable function that
doesn't require that and here is what I've been
using, which does (I think) required exclusive access...

function IsFieldInTable(const path : string;Table : TDbIsamTable;const
Fieldname : string) : boolean;
var
 exists : boolean;
begin
     exists := false;
     Table.RestructureFieldDefs.update;
     try
       exists := (Table.RestructureFieldDefs.IndexOf(Fieldname) <> -1);
     except
     end;
     result := exists;
end;

Is there a better way ?

How about just running a query on the table for the newly required field and
test the exception ?

Thanks all !

JT

Tue, Feb 27 2007 6:26 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

John,

<< I have a series of apps that use the same database and periodically I'll
need to add a new field somewhere, that's where the problem comes in.   I
know exclusive access is needed to add the field so if the other
applications are accessing the table it can't happen.  I would however like
an IsFieldInTable function that doesn't require that and here is what I've
been using, which does (I think) required exclusive access... >>

RestructureFieldDefs.Update does not require exclusive access.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image