Copy SQL or Copy Dataset

Hawkeye

Member
I have a wizard we created that exports the contents of a dataset to Excel. The wizard allows the user to select the columns, change the filter, change the column headings prior to performing the export. Currently, we are limited to exporting a table (or materialized view). I would like to be able to pass a dataset or fully Substituted SQL statement into the wizard. In a test I tried using the .SubstitutedSQL property but received an error stating that not all variables are defined
Ex:
NewDataset.SQL.AddStrings(OldDataset.SubstitutedSQL);
NewDataset.Active := True;
Error occurred.

One can assume that all the passed in datasets will have at least one variable.

In a post titled "Assign a toracledataset to another? " dated 15 September, 2003, ziller asked
is there a way to clone a toracledataset ? i mean myrorads2.assign(myorads1);
and you responded with
You will have to assign the individual properties to copy the dataset. All properties can be assigned though, even properties such as Variables, QBEDefinition, and so on.
Do I have to assign every single dataset properties or can I assign only those that might differ between the two datasets. For example, NewDataset.Variables.Assign(OldDataset.Variables) and NewDataset.SQL.Assign(OldDataset.SQL). If I don't need to assign them all can you suggest which ones I should always assign?

Thanks
Richard Anderson
 
You can assign just the properties that are different. Instead of using assign, you can simply do the following:

NewDataSet.Session := OldDataSet.Session;
NewDataSet.SQL := OldDataSet.SQL;
NewDataSet.Variables := OldDataSet.Variables;

This would be the minimum set of properties you need to assign.
 
Back
Top