Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access 7.1.252
  HXTT Cobol 5.0.251
  HXTT DBF 7.1.252
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Excel 6.1.255
  HXTT Json 1.0.223
  HXTT Paradox 7.1.251
  HXTT PDF 2.0.251
  HXTT Text(CSV) 7.1.251
  HXTT Word 1.1.251
  HXTT XML 4.0.252
Offshore Outsourcing
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
   
   
   
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)

Search Key   Search by Last 50 Questions




Google
 

Email: webmaster@hxtt.com
Copyright © 2003-2019 Heng Xing Tian Tai Lab of Xi'an City. | All Rights Reserved. | Privacy | Legal | Sitemap