Create text file from query

Ask a Question related to Coldfusion - Getting Started, Design and Development.

  1. #1

    Default Create text file from query

    I wantto create a simple text file from the requlsts of a query, but I can't
    seem to escape thequotes right.

    I am trying to run...

    <cfset ScrollerXML ="
    <cfoutput query='GetRates'>
    <country pkey="#CountryID#" scroller="#OnScroller#"
    rate="#CountryRate1#">#CountryName#</country>#chr(10)#
    </cfoutput>
    ">

    To give me a file that looks like:

    <country pkey="1" scroller="1" rate=".50">USA</country>
    <country pkey="2" scroller="0" rate=".75">GB</country>
    <country pkey="3" scroller="1" rate="1.50">USSR</country>

    how do I run that query insdie the <cfset> tag?

    Efused Guest

  2. Similar Questions and Discussions

    1. Coldfusion to create a PDF file from a query
      I use Coldfusion to create a PDF file from a query. Everything works fine, except that my PDF file only shows the first record from my query. If I...
    2. text file to query using cfhttp
      Did you ever find out what causes this issue? It's happening to me now... String index out of range: -1 Same situation, only I'm using a single...
    3. Create a table regarding a text file
      Hello, I have this .txt file : Roger|tow25$rank259 Isabelle|tow36$rank24 Pascal|tow12$rank29 Sergeď|tow45$rank5 Michel|tow1245$rank45478...
    4. Create text file from CD-ROM projector
      Hi, You need to write the file to a temporary location on the user's hard disk and then open that file to print.... Vj
    5. Cannot create a text file
      I have a simple guestbook application which writes all the entries made on the guestbook on a text file which I save at...
  3. #2

    Default Re: Create text file from query

    try using CHR(34) instead fo the quotes in the actual output

    I also don't think running a loop inside a variable assignment will properly
    work.

    Try creating the variable and concatenating within the loop rather than the
    opposite.

    ... then when done save the final variable result to a file using CFFILE

    <cfset txtdata = "">

    <cfoutput query='GetRates'>
    <cfset txtdata="#txtdata#<country pkey=#CHR(34)##CountryID##CHR(34)#
    scroller=#CHR(34)##OnScroller##CHR(34)#
    rate=#CHR(34)##CountryRate1##CHR(34)#>#CountryName #</country>#chr(10)#">
    </cfoutput>

    SafariTECH Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139