Arrays in Databases-How? 
Author Message
 Arrays in Databases-How?

Quote:

>I am looking for a way to put a 'field' on a Paradox table such that when
>I read the record into a delphi program I can access the 'field' as an
>array.
>I know I could set up two tables with a one-to-many relationship but that
>seems to be a lot of work for a few integers or short strings.  On the
>other hand, it also a hassle to deal with Integer1 ... Integer10.
>Will this work?...
>In Paradox, define the field as a string of an appropriate length.
>In Delphi, define the array as a var separate from the table.
>After reading the record from the table
>    Move(table.Field[1], array[1], SizeOf(WhichEverIsSmaller);
>WhichEverIsSmaller will take a little more investigation.

The Fields property is probably the way to go with this, but not quite in
the manner you asked. The syntax Table1.Fields[1] will return a reference
to the second field (as a whole), the Fields index starts counting at zero.
So, if you has the fields Integer1 through Integer10 and viewed these
fields as each an array element, then the syntax to retrieve the value from
the second "element" would be:

  var := Table1.Fields[1].AsInteger;

The fields in a record would act as one dimension in the "array" and the
table of such records would act as the other dimension (although you would
not be able to refer to points in that dimension by way of a numeric
index).

**************************************************************************
Steve Koterski
Local InterBase Server Technical Support
Borland International, Inc.



Sun, 15 Mar 1998 03:00:00 GMT  
 Arrays in Databases-How?

Quote:

> >I am looking for a way to put a 'field' on a Paradox table such that when
> >I read the record into a Delphi program I can access the 'field' as an
> >array.

Try

var
  MyArray [1..10] of whatever;
begin

and..

where
  MyField is defined as a TBytesField large enough for your array.

This seems to work fine.  But doesnt lend itself to easy changing.
The detail table route is better.



Tue, 24 Mar 1998 03:00:00 GMT  
 Arrays in Databases-How?

writes:
Quote:


>> >I am looking for a way to put a 'field' on a Paradox table such
that when
>> >I read the record into a Delphi program I can access the 'field' as
an
>> >array.

>Try

>var
>  MyArray [1..10] of whatever;
>begin

>and..

>where
>  MyField is defined as a TBytesField large enough for your array.

>This seems to work fine.  But doesnt lend itself to easy changing.
>The detail table route is better.

This is not so.  Fields in a Delphi tabel (paradox,etc) are already
indexed as an array.  the first field would be Table1[0] and so on.
You can access fields that way, however it is preferable to use the
fieldbyname distinction since if you restructure and add a field all
your code has to modified.
Ben
Arrow


Mon, 30 Mar 1998 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Dynamic array in database

2. Putting an array in an database???

3. Arrays in Databases-How?

4. Database Arrays

5. Arrays in a database

6. Databases who support array Fields ?

7. Databases who support array Fields?

8. LIMITED ARRAYS IN A DATABASE STRUCTURE

9. Arrays in databases

10. Using array's in database tables

11. Databases that allow arrays

12. Array of Array

 

 
Powered by phpBB® Forum Software