Accessing a Query in a structure

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Accessing a Query in a structure

    I am creating a session variable that is a structure. Each key in the structure
    stores a query that I created via QueryNew. I can output the query via cfdump
    and I can also access a value from the first row by accessing the column
    directly, but when trying to loop through the query, I get an error. Example
    lines of code follow:

    Outputs the query in its entirety:
    <cfdump var="#session.CurrentRegInfo[747]#">

    Outputs the RegID field for first row:
    #session.CurrentRegInfo[747].RegID#

    Throws error
    <cfloop query="session.CurrentRegInfo[747]">

    Error thrown:
    The value of the attribute query, which is currently
    "session.CurrentRegInfo[747]", is invalid.

    Anyone with any ideas here?

    Matt

    mattw Guest

  2. Similar Questions and Discussions

    1. Newbie 'structure' design query
      I am trying to design a database to hold company names, company contacts, individuals etc. I'm new to databases, have read until my head hurts, but...
    2. Copy a table in Access structure only with CF query
      Hello, I need to know how to create a new table by copying an existing table with the table structure only in a query Don't know the Syntax but...
    3. Query w/bad table structure
      Hi, I am trying to query a column that has multiple values. When I export it, I need to have it so that each of those values is placed in its own...
    4. Query to Structure?
      Hi. I wanted to ask if someone knew how to do the following: I have a structure and a query. <cfset myStruct = StructNew()> <cfset...
    5. query to return table structure
      hi, Is there any command or query that returns the table structure informix.
  3. #2

    Default Re: Accessing a Query in a structure

    Is SESSION.CurrentRegInfo the query? if so, you need to take the [747] out of your <cfloop> call...

    <cfloop query="SESSION.CurrentRegInfo">


    Kronin555 Guest

  4. #3

    Default Re: Accessing a Query in a structure

    No, session.CurrentRegInfo is the structure. The first key in this structure is
    [747]. That key holds a query. The cfdump tag I posted outputs a query. Maybe
    there is an issue with a structure key being numeric. I'll try that and get
    back...

    mattw Guest

  5. #4

    Default Re: Accessing a Query in a structure

    Okay, so adding some letters before the numbers did nothing. However, I have
    found a fix. Set a variable to hold the query.

    <cfset tmp_qry = session.CurrentRegInfo[747]>
    <cfloop query="tmp_qry">
    ...

    This seems to work, although it seems I shouldn't have to do this. Perhaps I
    found an Undocumented Feature (bug).

    Matt

    mattw 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