Preventing Redundant Record Export
Preventing Redundant Record Export
HI All,
I have a table with redundant records. I need to export the data to a text file but I only want one occurrence of each record exported. For example.. Suppose I have a "Names" table with multiple John Doe records. I can list the records in groups but how do I export the records in groups? The following script below does not work. I get an (see uploaded image) error. I'm sure it is a simple fix. Your help would be greatly appreciated. Thank You..
for Names ;
List records
LastName in groups ;
FirstName in groups .
end
export to "c:\ExportData\ExpData.txt" .
.form header
LAST NAME`FIRST NAME
.items
@f[1,1]`@f[1,2]
.end
Re:Preventing Redundant Record Export
Redundancy is the eye of the beholder...
You will have to define what that means ;-)
However lets say that if both FirstName and LastName is the same it is redundant you do it like this:
define "vFirstName" text .
define "vlastName" text .
for Names ;
if vLastname not=LastName and vFirstName not=firstname
List records
LastName in order ;
FirstName in order .
vLastname :=LastName .
vFirstName := FirstName .
end
end
export to "c:\ExportData\ExpData.txt" .
.form header
LAST NAME`FIRST NAME
.items
@f[1,1]`@f[1,2]
.end
You can do it with groups too but its more awkward and I'm not sure how good this export format is on groups.
Re:Re:Preventing Redundant Record Export
Thank you. That worked great.
Re:Re:Re:Preventing Redundant Record Export
Oops. I lied it didn't work. Suppose I have 2 or more records with the first name of John and the last name of Doe. I only want one John Doe record exported. I don't need all of them exported. This wouldn't be a case where both the first and last names are the same.
Re:Re:Re:Re:Preventing Redundant Record Export
Sorry.
Boolean problem.
it should of course be or and not and in the if.
if vLastname not=LastName or vFirstName not=firstname then
All of it.
define "vFirstName" text .
define "vlastName" text .
for Names ;
if vLastname not=LastName or vFirstName not=firstname then
List records
LastName in order ;
FirstName in order .
vLastname :=LastName .
vFirstName := FirstName .
end
end
export to "c:\ExportData\ExpData.txt" .
.form header
LAST NAME`FIRST NAME
.items
@f[1,1]`@f[1,2]
.end
Re:Re:Re:Re:Re:Preventing Redundant Record Export
This way of exporting is outdated as it was never very good and was just added as an afterthought back in 1995 when they realised that you couldn't export from DQL...
ExecDQL is a better way of generating exports.
The funny thing is also that your DQL actually work out of the box in ExecDQL as it attack the columns and sections in a different way (i.e. more like DFD).
Attached a quick sample.