copying data from one record to the next when inserting a new record 
Author Message
 copying data from one record to the next when inserting a new record

hello,

        I would like to know if there is a way to copy one field of a
record to a newly created record.  I am using Interbase 3.3 server
version.  I have an OnNewRecord event for one of my tables and would
the data from the previous records VarChar field of length 32000
to be copied to the newly created field.  Is there an easy way to key
the varchar field in a temp variable or something so when the new record
is created it can just copy the data there.  Any help is appreciated.

Thanx in advance

Chad lind



Sat, 07 Feb 1998 03:00:00 GMT  
 copying data from one record to the next when inserting a new record

:       I would like to know if there is a way to copy one field of a
: record to a newly created record.  I am using Interbase 3.3 server
: version.  I have an OnNewRecord event for one of my tables and would
: the data from the previous records VarChar field of length 32000
: to be copied to the newly created field.  Is there an easy way to key
: the varchar field in a temp variable or something so when the new record
: is created it can just copy the data there.  Any help is appreciated.

The difficult aspect of this is the fact that only one record out of a
table is accessible at any one time. That means that once you move the
record pointer to another record, that data from the original record is
no longer available. So if this new record is the one into which you want
to carry data forward into, you would not have the other record's data at
hand.

If you could be sure that the "other" record would always be the preceding
one, this might be simple: just use another TTable pointing to the same
table, move to the current record, move back one record, and extract the
data. But moving through a table is almost always multi-directional. Worse
would be the case of data displayed in a TDBGrid, where you could arrive
at a new record from any number of other records, contiguous or 1,000
records away.

So how to "remember" needed values from the last record accessed? One way
might be to use a Pascal record with fields of names and types to corre-
spond to the fields in a table record. Then, on arriving at a new record,
the field values would be stored into the record. Actually, this would
require two such records, one to store the new record's data and one to
store the last accessed record. Before each new record is stored into the
Pascal record, the current one would be copied to the secondary Pascal
record so as not to be displaced by the new, incoming table record. This
storing process could be effected in the OnDataChange event procedure of
the TDataSource component.

Once at the new record, a keystroke might be provided the end-user to
trigger the copying of "remembered" data into the current table record.
On the occurrence of that keystroke, the program would copy the data
from the Pascal record into the fields of the table record.

--
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/ Steve Koterski               _/   The opinions expressed here are    _/

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/



Tue, 10 Feb 1998 03:00:00 GMT  
 copying data from one record to the next when inserting a new record

Quote:

>Before each new record is stored into the
>Pascal record, the current one would be copied to the secondary Pascal
>record so as not to be displaced by the new, incoming table record. This
>storing process could be effected in the OnDataChange event procedure of
>the TDataSource component.

>Once at the new record, a keystroke might be provided the end-user to
>trigger the copying of "remembered" data into the current table record.
>On the occurrence of that keystroke, the program would copy the data
>from the Pascal record into the fields of the table record.

Would there be a way to set up an array based on reading the structure of
the table?  Then copying the contents of a selected record to this array,
asking the user for the new index value(s), then inserting a record with
the new index values and the selected record's field values?

Thanks,
Paul Rice



Thu, 12 Feb 1998 03:00:00 GMT  
 copying data from one record to the next when inserting a new record

Quote:


>:   I would like to know if there is a way to copy one field of a
>: record to a newly created record.  I am using Interbase 3.3 server
>: version.  I have an OnNewRecord event for one of my tables and would
>: the data from the previous records VarChar field of length 32000
>: to be copied to the newly created field.  Is there an easy way to key
>: the varchar field in a temp variable or something so when the new record
>: is created it can just copy the data there.  Any help is appreciated.
>The difficult aspect of this is the fact that only one record out of a
>table is accessible at any one time. That means that once you move the
>record pointer to another record, that data from the original record is
>no longer available. So if this new record is the one into which you want
>to carry data forward into, you would not have the other record's data at
>hand.
>If you could be sure that the "other" record would always be the preceding
>one, this might be simple: just use another TTable pointing to the same
>table, move to the current record, move back one record, and extract the
>data. But moving through a table is almost always multi-directional. Worse
>would be the case of data displayed in a TDBGrid, where you could arrive
>at a new record from any number of other records, contiguous or 1,000
>records away.
>So how to "remember" needed values from the last record accessed? One way
>might be to use a Pascal record with fields of names and types to corre-
>spond to the fields in a table record. Then, on arriving at a new record,
>the field values would be stored into the record. Actually, this would
>require two such records, one to store the new record's data and one to
>store the last accessed record. Before each new record is stored into the
>Pascal record, the current one would be copied to the secondary Pascal
>record so as not to be displaced by the new, incoming table record. This
>storing process could be effected in the OnDataChange event procedure of
>the TDataSource component.
>Once at the new record, a keystroke might be provided the end-user to
>trigger the copying of "remembered" data into the current table record.
>On the occurrence of that keystroke, the program would copy the data
>from the Pascal record into the fields of the table record.

Steve, could you not use two TTable components and keep the 'old' data attached
to one via a bookmark and just transfer from one set of field arrays to the
other?

- Show quoted text -

Quote:
>--
>_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
>_/ Steve Koterski               _/   The opinions expressed here are    _/

>_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/



Sat, 14 Feb 1998 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Copying records from one table to another?

2. Copying a record from one Ttable to another

3. How to copy field's value from one record to a new record ?

4. Copy/New Record creation help needed...

5. Inserting new records

6. On New Record - After Insert

7. Efficient way to insert a new, similar record

8. Help-Having trouble to inserting the new record - ctnsho~1.pas (0/2)

9. Problem inserting new records in PDX 5-file

10. trapping key violation error when inserting new record using SQL

11. Help-having troubles inserting new record - ctnsho~1.pas (2/2)

12. Help-having troubles inserting new record - ctnsho~1.pas (1/2)

 

 
Powered by phpBB® Forum Software