Log in

View Full Version : Write 2 queries to a file



jmentor
12-10-2005, 04:21 AM
I would like help on how to write the contents of
2 different queries to a fixed length file and then
name the file based on the value held in field 2
of the first query.
eg. 5 fields from query1. 6 fields from query2
Even better if I could supply some criteria before
writing the contents to a file.

Any help appreciated and hope I have made
myself clear.

Thanks

Jmentor

matthewspatrick
12-10-2005, 06:57 PM
I would like help on how to write the contents of
2 different queries to a fixed length file and then
name the file based on the value held in field 2
of the first query.
eg. 5 fields from query1. 6 fields from query2

By 'fixed length', do you mean 'fixed width'? I.e.,
columns are defined by character position?

Also, are these queries defined in the db, or are they generated in code? Can you define the import/export specs in the db? (Easiest way is to use the Import Text File Wizard, click Advanced, set up the spec and then save it.)


Even better if I could supply some criteria before
writing the contents to a file.


Why not just bake the criteria into the queries?


Any help appreciated and hope I have made
myself clear.

Thanks

Jmentor

Well, sort of :whistle:

jmentor
12-11-2005, 05:54 AM
matthewspatrick
Yes, fixed width
Has to be 2 queries because they hold
different data type and number of fields
are different.
Need to write 2 lines of a query to the file
followed by other lines from the other query
Is it possible ?

Thanks
J

matthewspatrick
12-11-2005, 12:06 PM
matthewspatrick
Yes, fixed width
Has to be 2 queries because they hold
different data type and number of fields
are different.
Need to write 2 lines of a query to the file
followed by other lines from the other query
Is it possible ?

Thanks
J

It's entirely possible, but I will need you to be very explicit about the following:


Are the queries generated in code, or are they predefined in the database?
How are the two lines from Query1 chosen? And is there any chance that the definition of Query1 can be modified to select only those two rows?
Is there any filtering going on for Query2?
What are the complete export specs for each query? I.e., print column names or not; list the fields with data types, formats, and lengths; what should be used to pad the fields (space, period, some letter--can be different by field, but you have to be specific); does the padding come before or after the value.

Regards,

Patrick

jmentor
12-11-2005, 01:57 PM
matthewspatrick

Thanks for your help and interest.
The queries are already defined in the
database.
The first line of query1 is chosen (sorry for
saying 2 line)and written to the file. This cannot
be changed.
Only filtering is that the ID field value is the
same as that in query1.
Do not print column names
Padding can be by space
Padding to come after the value

How this answers your reply.
Thanks

matthewspatrick
12-11-2005, 02:18 PM
I still need you to specify the field widths :dunno

jmentor
12-11-2005, 02:56 PM
matthewspatrick

Sorry..
Widths of fields in query1
5,7,8,8,20,20,20
Widths of fields in query2
10,10,20,10,10,15

Thanks