Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Problem with re-creating primary index
Wed, Apr 8 2009 7:27 AMPermanent Link

Colin
Hi Guys,

I am using the following code...
       Query1.SQL.Clear;
       Query1.SQL.Add('DROP INDEX IF EXISTS RemoteSites.Primary;');
       Query1.SQL.add('ALTER TABLE "RemoteSites.dat"');
       Query1.SQL.Add('add Primary Key(KnownAs,Site);');
       Query1.ExecSQL;

When I run the code I get the error "Error 11949 - Cannot REDEFINE and existing primary
index using the ADD keyword in Alter Table SQL".
I thought by deleting the primary code on the first line, I couldn't be redefining the
primary index.

Am I missing something obvious? Any help appreciated.

(Using D5 last DBISAM version)

Colin
Mon, Apr 13 2009 6:22 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Colin,

<< When I run the code I get the error "Error 11949 - Cannot REDEFINE and
existing primary index using the ADD keyword in Alter Table SQL". I thought
by deleting the primary code on the first line, I couldn't be redefining the
primary index.

Am I missing something obvious? Any help appreciated. >>

It's not that obvious, but DBISAM 4.x requires a primary key/index for every
table, so when you drop the existing primary key/index, it will result in
DBISAM automatically creating one on the system-defined RecordID field.
Thus, you should never use ADD for primary keys in an ALTER TABLE statement,
but rather always use REDEFINE.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image