Coping a DataSet

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Coping a DataSet

Marcos Douglas B. Santos
Hi,

What is the faster way to copy a DataSet to another?
The FPC provides some functionality for this?

Thanks,
Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Coping a DataSet

silvioprog
Guys,

Is "Assign" method implemented for dataset in FPC?

2012/12/3 Marcos Douglas <[hidden email]>
Hi,

What is the faster way to copy a DataSet to another?
The FPC provides some functionality for this?

Thanks,
Marcos Douglas
 
--
Silvio Clécio
My public projects - github.com/silvioprog

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Coping a DataSet

michael.vancanneyt


On Mon, 3 Dec 2012, silvioprog wrote:

> Guys,
>
> Is "Assign" method implemented for dataset in FPC?

No, it is not.
Datasets differ wildly in how they access and store data.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Coping a DataSet

Marcos Douglas B. Santos
On Mon, Dec 3, 2012 at 2:03 PM,  <[hidden email]> wrote:

>
>
> On Mon, 3 Dec 2012, silvioprog wrote:
>
>> Guys,
>>
>> Is "Assign" method implemented for dataset in FPC?
>
>
> No, it is not. Datasets differ wildly in how they access and store data.
>
> Michael.

But all descendents use TFieds classes so, why not?
I can use a loop and the Append method, but this is not faster.

Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Coping a DataSet

Michael Van Canneyt


On Mon, 3 Dec 2012, Marcos Douglas wrote:

> On Mon, Dec 3, 2012 at 2:03 PM,  <[hidden email]> wrote:
>>
>>
>> On Mon, 3 Dec 2012, silvioprog wrote:
>>
>>> Guys,
>>>
>>> Is "Assign" method implemented for dataset in FPC?
>>
>>
>> No, it is not. Datasets differ wildly in how they access and store data.
>>
>> Michael.
>
> But all descendents use TFieds classes so, why not?
> I can use a loop and the Append method, but this is not faster.

Speed is not the issue.

There is simply no way to tell what this action will do behind the scenes.

You might for example generate a huge amount of queries, which will presumably
all fail, since the records already exist in the database.

Then: Should the transaction be copied ? etc. etc. etc.

In short: it is not implemented, and I doubt it every will be, at least at the TDataset level.

When using a pure TBufDataset, probably it is possible to copy the data package
(much like TClientDataset in Delphi), but this would need to be implemented.


Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Coping a DataSet

Marcos Douglas B. Santos
On Mon, Dec 3, 2012 at 2:32 PM, Michael Van Canneyt
<[hidden email]> wrote:

>
>
> On Mon, 3 Dec 2012, Marcos Douglas wrote:
>
>> On Mon, Dec 3, 2012 at 2:03 PM,  <[hidden email]> wrote:
>>>
>>>
>>>
>>> On Mon, 3 Dec 2012, silvioprog wrote:
>>>
>>>> Guys,
>>>>
>>>> Is "Assign" method implemented for dataset in FPC?
>>>
>>>
>>>
>>> No, it is not. Datasets differ wildly in how they access and store data.
>>>
>>> Michael.
>>
>>
>> But all descendents use TFieds classes so, why not?
>> I can use a loop and the Append method, but this is not faster.
>
>
> Speed is not the issue.
>
> There is simply no way to tell what this action will do behind the scenes.
>
> You might for example generate a huge amount of queries, which will
> presumably all fail, since the records already exist in the database.

I guess I didn't understand you, sorry (thanks for the patience).
I'm talking about copy the data only in memory. Do not is necessary
check if record already exists.

> Then: Should the transaction be copied ? etc. etc. etc.
>

I want, eg., copy a TZQuery (Zeos) to a TSQLQuery or TBufDataSet.

> In short: it is not implemented, and I doubt it every will be, at least at
> the TDataset level.

I see.
Well, I wont to compare, but C# have ds.Copy and ds.Clone. I needed
something like that.
http://msdn.microsoft.com/en-us/library/system.data.dataset.copy.aspx

> When using a pure TBufDataset, probably it is possible to copy the data
> package
> (much like TClientDataset in Delphi), but this would need to be implemented.

Yes, like a TClientDataSet -- but I think this code is in midas.dll.
The ClientDataSet copy data from whatever TDataSet descendent to him
and this is fast.

Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Coping a DataSet

silvioprog
dbExpress, IBQuery or Zeos implements it?


2012/12/3 Marcos Douglas <[hidden email]>
On Mon, Dec 3, 2012 at 2:32 PM, Michael Van Canneyt
<[hidden email]> wrote:
>
>
> On Mon, 3 Dec 2012, Marcos Douglas wrote:
>
>> On Mon, Dec 3, 2012 at 2:03 PM,  <[hidden email]> wrote:
>>>
>>>
>>>
>>> On Mon, 3 Dec 2012, silvioprog wrote:
>>>
>>>> Guys,
>>>>
>>>> Is "Assign" method implemented for dataset in FPC?
>>>
>>>
>>>
>>> No, it is not. Datasets differ wildly in how they access and store data.
>>>
>>> Michael.
>>
>>
>> But all descendents use TFieds classes so, why not?
>> I can use a loop and the Append method, but this is not faster.
>
>
> Speed is not the issue.
>
> There is simply no way to tell what this action will do behind the scenes.
>
> You might for example generate a huge amount of queries, which will
> presumably all fail, since the records already exist in the database.

I guess I didn't understand you, sorry (thanks for the patience).
I'm talking about copy the data only in memory. Do not is necessary
check if record already exists.

> Then: Should the transaction be copied ? etc. etc. etc.
>

I want, eg., copy a TZQuery (Zeos) to a TSQLQuery or TBufDataSet.

> In short: it is not implemented, and I doubt it every will be, at least at
> the TDataset level.

I see.
Well, I wont to compare, but C# have ds.Copy and ds.Clone. I needed
something like that.
http://msdn.microsoft.com/en-us/library/system.data.dataset.copy.aspx

> When using a pure TBufDataset, probably it is possible to copy the data
> package
> (much like TClientDataset in Delphi), but this would need to be implemented.

Yes, like a TClientDataSet -- but I think this code is in midas.dll.
The ClientDataSet copy data from whatever TDataSet descendent to him
and this is fast.

Marcos Douglas

--
Silvio Clécio
My public projects - github.com/silvioprog

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Coping a DataSet

Marcos Douglas B. Santos
On Mon, Dec 3, 2012 at 2:56 PM, silvioprog <[hidden email]> wrote:

>
> 2012/12/3 Marcos Douglas <[hidden email]>
>>
>> On Mon, Dec 3, 2012 at 2:32 PM, Michael Van Canneyt
>> <[hidden email]> wrote:
>> >
>> >
>> > On Mon, 3 Dec 2012, Marcos Douglas wrote:
>> >
>> >> On Mon, Dec 3, 2012 at 2:03 PM,  <[hidden email]> wrote:
>> >>>
>> >>>
>> >>>
>> >>> On Mon, 3 Dec 2012, silvioprog wrote:
>> >>>
>> >>>> Guys,
>> >>>>
>> >>>> Is "Assign" method implemented for dataset in FPC?
>> >>>
>> >>>
>> >>>
>> >>> No, it is not. Datasets differ wildly in how they access and store
>> >>> data.
>> >>>
>> >>> Michael.
>> >>
>> >>
>> >> But all descendents use TFieds classes so, why not?
>> >> I can use a loop and the Append method, but this is not faster.
>> >
>> >
>> > Speed is not the issue.
>> >
>> > There is simply no way to tell what this action will do behind the
>> > scenes.
>> >
>> > You might for example generate a huge amount of queries, which will
>> > presumably all fail, since the records already exist in the database.
>>
>> I guess I didn't understand you, sorry (thanks for the patience).
>> I'm talking about copy the data only in memory. Do not is necessary
>> check if record already exists.
>>
>> > Then: Should the transaction be copied ? etc. etc. etc.
>> >
>>
>> I want, eg., copy a TZQuery (Zeos) to a TSQLQuery or TBufDataSet.
>>
>> > In short: it is not implemented, and I doubt it every will be, at least
>> > at
>> > the TDataset level.
>>
>> I see.
>> Well, I wont to compare, but C# have ds.Copy and ds.Clone. I needed
>> something like that.
>> http://msdn.microsoft.com/en-us/library/system.data.dataset.copy.aspx
>>
>> > When using a pure TBufDataset, probably it is possible to copy the data
>> > package
>> > (much like TClientDataset in Delphi), but this would need to be
>> > implemented.
>>
>> Yes, like a TClientDataSet -- but I think this code is in midas.dll.
>> The ClientDataSet copy data from whatever TDataSet descendent to him
>> and this is fast.
>>
>> Marcos Douglas
>
> dbExpress, IBQuery or Zeos implements it?

I do not know about IBQuery or Zeos. The dbExpress, AFAIK, is used
together TClientDataSet so, it no needs this functionality, I guess.

Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Coping a DataSet

anatolamike
This post has NOT been accepted by the mailing list yet.
To create a copy of a DataSet that only includes schema, use the Clone method of the DataSet. You can also add existing rows to the cloned DataSet using the ImportRow method of the DataTable. ImportRow adds data, row state, and row version information to the specified table. Column values are added only where the column name matches and the data type is compatible.

The following code example creates a clone of a DataSet and then adds the rows from the original DataSet to the Customers table in the DataSet clone for customers where the CountryRegion column has the value "Germany".



DJs Chicago
dj services Chicago