|
Heng Xing Tian Tai Lab of Xi'an City (abbr, HXTT)
HXTT DBF
|
sql error when inserting into table with compound primary key |
Rob Gansevles |
2009-02-23 05:34:49 |
Hi,
I get an sql error when I insert a few rows in a table with composite primary keys.
Am I doing something wrong?
Is this even supported in the dbf driver?
See the sql below.
Thanks
Rob
create table tst (id1 integer not null, id2 integer not null, val integer not null, primary key (id1, id2))
insert into tst (id1, id2, val) values (1, 2, 0)
insert into tst (id1, id2, val) values (1, 3, 0)
insert into tst (id1, id2, val) values (2, 2, 0)
|
Re:sql error when inserting into table with compound primary key |
HXTT Support |
2009-02-23 06:29:30 |
But Xbase doesn't support composite primary keys. primary key (id1, id2) will become id1+id2.
create table tst (id1 varchar(11) not null, id2 varchar(11) not null, val integer not null, primary key (id1, id2))
insert into tst (id1, id2, val) values (1, 2, 0)
insert into tst (id1, id2, val) values (1, 3, 0)
insert into tst (id1, id2, val) values (2, 2, 0)
or
create table tst (id1 varchar(11) not null, id2 varchar(11) not null, val integer not null)
create index primary_key on tst (LPAD(id1,11)+LPAD( id2,11) UNIQUE)
insert into tst (id1, id2, val) values (1, 2, 0)
insert into tst (id1, id2, val) values (1, 3, 0)
insert into tst (id1, id2, val) values (2, 2, 0)
|
Re:Re:sql error when inserting into table with compound primary key |
HXTT Support |
2009-02-23 06:31:30 |
Sorry, for second sample, you can use int type:
create table tst (id1 int not null, id2 int not null, val integer not null)
create index primary_key on tst (LPAD(id1,11)+LPAD( id2,11) UNIQUE)
insert into tst (id1, id2, val) values (1, 2, 0)
insert into tst (id1, id2, val) values (1, 3, 0)
insert into tst (id1, id2, val) values (2, 2, 0)
|
|
|