Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to create a text file from a query

Participant ,
Jul 31, 2008 Jul 31, 2008
I need to generate a text file with CF. What I have is a query result with the values from 3 columns, OrderID, VersionID and Amount. I need to generate something like this:
0000123 | 002 | 1
0000124 | 002 | 2
0000125 | 002 | 5
0000126 | 002 | 1 and so on

I know I have to use <CFFILE action="write" file="#somepath#Invoice.txt .....>
but I'm not sure how can I output my query result into this text file??????
Please help....


TOPICS
Advanced techniques
509
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 31, 2008 Jul 31, 2008
LATEST
A couple of ways.

1) You loop over the query and output it into a text variable then write
the text variable to the file. You can use string concatenation to
build the variable OR the <cfsavecontent...> tag on the more recent
flavors of CF.

2) You loop over the query and append the output to the file.

The choice between one and two is largely how is the file
created|updated? If it is done all at once then option one is a bit
more performerent. If the file grows over time then option two is the
way to go.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources