Board index » delphi » Master/Detail - field index out of range

Master/Detail - field index out of range

The foreign key fields in the detail table must match the primary key in the
master table. If the primary key of the master is a longint and a smallint
then the secondary index of the detail table which is used for the link must
have at least a longint and a smallint to match the fields in the master's
primary key.

--
Bill Todd (TeamB)
Please do not send questions via email.

 

Re:Master/Detail - field index out of range


The master/detail relationship is set using the MasterSource and the
MasterFields properties for the Detail table (and the primary key matches
the foreign key). In addition I want to sort the detail table on the
secondary index, that's why I set the IndexName property to that secondary
index (for the Detail table). But that obviously results in a conflict as
the primary index in the Master table automatically is filled in the
secondary index for the Detail table (when inserting rows in the grid in
master/detail form).
How can I then sort the rows in the detail table on a secondary index?

Tove

"Bill Todd (TeamB)" <b...@dbginc.com> wrote in message
news:3a3130df$1_2@dnews...

Quote
> The foreign key fields in the detail table must match the primary key in
the
> master table. If the primary key of the master is a longint and a smallint
> then the secondary index of the detail table which is used for the link
must
> have at least a longint and a smallint to match the fields in the master's
> primary key.

> --
> Bill Todd (TeamB)
> Please do not send questions via email.

Re:Master/Detail - field index out of range


A TTable can only have one active index. In the case of a detail table that
_must_ be the index on the foreign key that is used for the link. You cannot
set the IndexName property of a detail TTable. To sort the detail table in
some particular order create a secondary index whose first N fields are the
foreign key fields followed by the fields you want to sort on then use that
index when you set the MasterFields property.

--
Bill Todd (TeamB)
Please do not send questions via email.

Re:Master/Detail - field index out of range


I have two tables in master/detail relationship. Foreign key in the detail
table matches
 the primary key in the master table. Master table key  has one field: Fie
ld1 (type number). Detail table has key with two fields: Field1 as the same
name and type what has master table and Field2 (type number) that's used for
sorting detail table.
I've got message about error  "detailtable: Field index out of range"  while
I set property "active" in detail table.
    What is wrong ?

Re:Master/Detail - field index out of range


Quote
>I've got message about error  "detailtable: Field index out of range"  while
>I set property "active" in detail table.

There is something wrong with the detail index it probably is not the correct
index.  Try resetting your MasterFields property.
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Master/Detail - field index out of range


 I change type of tables to paradox. Now it works correctly. I don't now why
doesn't work in DBASE IV tables. I try on new maked tables and indexes and
still not work.
Tell me is that possible in paradox tables set key (index) to:  key1+key2
unique ( not key1(unique) + key2( unique))
Thank's for request.

Re:Master/Detail - field index out of range


Quote
> I change type of tables to paradox. Now it works correctly. I don't now why
>doesn't work in DBASE IV tables. I try on new maked tables and indexes and
>still not work.
>Tell me is that possible in paradox tables set key (index) to:  key1+key2

That is the way Key fields in Paradox work.  
Dbase doesn't have true multi field indexes and expression indexes don't work
for linking master/detail using the masterfields property
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Master/Detail - field index out of range


Brian Bushay TeamB <BBus...@Nmpls.com> wrote

Quote
> > I change type of tables to paradox. Now it works correctly. I don't now
why
> >doesn't work in DBASE IV tables. I try on new maked tables and indexes
and
> >still not work.
> >Tell me is that possible in paradox tables set key (index) to:  key1+key2

> That is the way Key fields in Paradox work.
> Dbase doesn't have true multi field indexes and expression indexes don't
work
> for linking master/detail using the masterfields property
> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Yes it's possible to create index key1 + key2. Problem is in situation where
key1+key2 is unique in database - not ->key1 is unique and key2 is unique.
When I have to insert record to table with fields field1,field2(indexes
key1,key2)
 for example: field1:=aaa, field2:=bbb and another record field1:=aaa
field2:=ccc
now I have key violation error (key1->unique, key2->unique).

Have you any ideas how can I do this? (using index, not serching duplicate
records before inserting)

Re:Master/Detail - field index out of range


Quote
>Yes it's possible to create index key1 + key2. Problem is in situation where
>key1+key2 is unique in database - not ->key1 is unique and key2 is unique.
>When I have to insert record to table with fields field1,field2(indexes
>key1,key2)

I am having trouble making sense of your message.  In a Paradox primary index
the combinations of any fields in the index must be unique.  
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Master/Detail - field index out of range


Brian Bushay TeamB wrote
napisa3:jbun3tc213obnsjqe3pbr6q81i4rr29...@4ax.com...

Quote
> >Yes it's possible to create index key1 + key2. Problem is in situation
where
> >key1+key2 is unique in database - not ->key1 is unique and key2 is
unique.
> >When I have to insert record to table with fields field1,field2(indexes
> >key1,key2)

> I am having trouble making sense of your message.  In a Paradox primary
index
> the combinations of any fields in the index must be unique.
> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

My paradox table has structure: Field1, Field2, Field3 etc.
field1    type autoincrement (primary index)
field2 type alpha, field3  type longinteger (secondary index field2,field3)

Can i create index (secondary) where field2+field3 having unique value? (as
expression index  in DBASE)
example:
field2: name of book
field3: number of page in this book

table has records:
field2:  book1  field3:  1
field2:  book1  field3:  2
..........
field2:  book1  field3:  100

If i set the unique property ind secondary index and try inserting record:
field2:   book1    field3:101
I have key violation error.

If  secondary index is not unique I can insert the same records to table:

field2:  book1  field3:  1
field2:  book1  field3:  1
field2:  book1  field3:  1
field2:  book1  field3:  2

I don't want insert the same records to table !!!
Can I use index expression?
How set index?
If this impossible, what is another way  to do this ?

Re:Master/Detail - field index out of range


Quote
>My paradox table has structure: Field1, Field2, Field3 etc.
>field1    type autoincrement (primary index)
>field2 type alpha, field3  type longinteger (secondary index field2,field3)

>Can i create index (secondary) where field2+field3 having unique value? (as
>expression index  in DBASE)

No Paradox unique indexes allow only one record with the value of a unique
index.  This is the standard way for a unique index to work.  Dbase unique
indexes are just plain weird they allow multiple records with the same value
they just don't allow you to see more then one of the records

Quote
>I don't want insert the same records to table !!!

If this is what you want then a Pradadox unique index should be what you want.

Quote
>Can I use index expression?

Paradox does not have expression indexes

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads