Professional Web Applications Themes

PARSING A QUERY OF QUERY WITH A VARIABLE VALUE - Coldfusion Component Development

On my first page the user selects a project. I am using the variable SelectedProject: <cfset SelectedProject = '<cfoutput>#ArrayGroupAwards[8]#</cfoutput>'> I've tried whichever way to tease relevant data from my database by making the selected project a necessary condition for the data to qualify for inclusion. Here's one example: Query Of continued...

  1. #1

    Default PARSING A QUERY OF QUERY WITH A VARIABLE VALUE

    On my first page the user selects a project. I am using the variable
    SelectedProject:
    <cfset SelectedProject = '<cfoutput>#ArrayGroupAwards[8]#</cfoutput>'>

    I've tried whichever way to tease relevant data from my database by
    making the selected project a necessary condition for the data to
    qualify for inclusion. Here's one example:

    Query Of Queries syntax error.
    Encountered "Project. Incorrect conditional expression, Incorrect
    conditional expression, Lexical error at line 0, column 0. Encountered:
    "\"" (34), after : ""

    The error occurred in
    C:\CFusionMX7\wwwroot\Awards\Forms\edit_GroupAward Nomination_FORM.cfm:
    line 414
    Called from
    C:\CFusionMX7\wwwroot\Awards\Forms\edit_GroupAward Nomination_FORM.cfm:
    line 1
    Called from
    C:\CFusionMX7\wwwroot\Awards\Forms\edit_GroupAward Nomination_FORM.cfm:
    line 414
    Called from
    C:\CFusionMX7\wwwroot\Awards\Forms\edit_GroupAward Nomination_FORM.cfm:
    line 1

    412 : SELECT Project, FirstName, LastName
    413 : FROM Nominations
    414 : WHERE Project = "#SelectedProject#"
    415 : </cfquery>
    416 : <cfset counter = 0 />

    (Of course it works when I substitute the value of #SelectedProject# in
    the place of the variable. I just don't know how to the programming
    code substitute it in the WHERE statement so that it works.)

    As witnnessed by the following code line, my ColdFusion debugger
    somehow knows the properly parsed name of the project passed to the
    second page and even shows it in the WHERE statement:

    SQL SELECT Project, FirstName, LastName FROM Nominations
    WHERE Project = "<cfoutput>Fox River Team </span></cfoutput>"

    Why then am I getting the error?

    I have also tried, among other things,
    WHERE Project IN (<cfqueryparam cfsqltype="cf_sql_longvarchar"
    value="#SelectedProject#" list="yes" separator=",">)
    This does not result in an error, but in no results being displayed at
    all.

    Can you, would you help? Thanks.

    zdenek@gmail.com Guest

  2. #2

    Default Re: PARSING A QUERY OF QUERY WITH A VARIABLE VALUE

    Hey there zdenek,

    Firstly you might want to try the following for your cfset:
    <cfset SelectedProject = '#ArrayGroupAwards[8]#'>

    You don't need the <cfoutput> tags when assigning variables.

    Now if for some reason - that doesn't fix you up,
    please include a few more details in your email.
    Ie. How you create the instance of your CFC
    Whether or not the code you're running is in a function,
    How you're calling / using the function.

    Any and all of these things could have an effect a successful outcome.



    [email]zdenek@gmail.com[/email] wrote:
    > On my first page the user selects a project. I am using the variable
    > SelectedProject:
    > <cfset SelectedProject = '<cfoutput>#ArrayGroupAwards[8]#</cfoutput>'>
    >
    > I've tried whichever way to tease relevant data from my database by
    > making the selected project a necessary condition for the data to
    > qualify for inclusion. Here's one example:
    >
    > Query Of Queries syntax error.
    > Encountered "Project. Incorrect conditional expression, Incorrect
    > conditional expression, Lexical error at line 0, column 0. Encountered:
    > "\"" (34), after : ""
    >
    > The error occurred in
    > C:\CFusionMX7\wwwroot\Awards\Forms\edit_GroupAward Nomination_FORM.cfm:
    > line 414
    > Called from
    > C:\CFusionMX7\wwwroot\Awards\Forms\edit_GroupAward Nomination_FORM.cfm:
    > line 1
    > Called from
    > C:\CFusionMX7\wwwroot\Awards\Forms\edit_GroupAward Nomination_FORM.cfm:
    > line 414
    > Called from
    > C:\CFusionMX7\wwwroot\Awards\Forms\edit_GroupAward Nomination_FORM.cfm:
    > line 1
    >
    > 412 : SELECT Project, FirstName, LastName
    > 413 : FROM Nominations
    > 414 : WHERE Project = "#SelectedProject#"
    > 415 : </cfquery>
    > 416 : <cfset counter = 0 />
    >
    > (Of course it works when I substitute the value of #SelectedProject# in
    > the place of the variable. I just don't know how to the programming
    > code substitute it in the WHERE statement so that it works.)
    >
    > As witnnessed by the following code line, my ColdFusion debugger
    > somehow knows the properly parsed name of the project passed to the
    > second page and even shows it in the WHERE statement:
    >
    > SQL SELECT Project, FirstName, LastName FROM Nominations
    > WHERE Project = "<cfoutput>Fox River Team </span></cfoutput>"
    >
    > Why then am I getting the error?
    >
    > I have also tried, among other things,
    > WHERE Project IN (<cfqueryparam cfsqltype="cf_sql_longvarchar"
    > value="#SelectedProject#" list="yes" separator=",">)
    > This does not result in an error, but in no results being displayed at
    > all.
    >
    > Can you, would you help? Thanks.
    TroubZ Guest

  3. #3

    Default Re: PARSING A QUERY OF QUERY WITH A VARIABLE VALUE

    Gavin,

    Thanks for taking the time to respond.

    I took out the cfoutput tags. It didn't help. I sent you the two pages
    in case you have the time and the inclination to look them over for me.
    :-)

    TroubZ wrote:
    > Hey there zdenek,
    >
    > Firstly you might want to try the following for your cfset:
    > <cfset SelectedProject = '#ArrayGroupAwards[8]#'>
    >
    > You don't need the <cfoutput> tags when assigning variables.
    >
    > Now if for some reason - that doesn't fix you up,
    > please include a few more details in your email.
    > Ie. How you create the instance of your CFC
    > Whether or not the code you're running is in a function,
    > How you're calling / using the function.
    >
    > Any and all of these things could have an effect a successful outcome.
    >
    >
    >
    > [email]zdenek@gmail.com[/email] wrote:
    > > On my first page the user selects a project. I am using the variable
    > > SelectedProject:
    > > <cfset SelectedProject = '<cfoutput>#ArrayGroupAwards[8]#</cfoutput>'>
    > >
    > > I've tried whichever way to tease relevant data from my database by
    > > making the selected project a necessary condition for the data to
    > > qualify for inclusion. Here's one example:
    > >
    > > Query Of Queries syntax error.
    > > Encountered "Project. Incorrect conditional expression, Incorrect
    > > conditional expression, Lexical error at line 0, column 0. Encountered:
    > > "\"" (34), after : ""
    > >
    > > The error occurred in
    > > C:\CFusionMX7\wwwroot\Awards\Forms\edit_GroupAward Nomination_FORM.cfm:
    > > line 414
    > > Called from
    > > C:\CFusionMX7\wwwroot\Awards\Forms\edit_GroupAward Nomination_FORM.cfm:
    > > line 1
    > > Called from
    > > C:\CFusionMX7\wwwroot\Awards\Forms\edit_GroupAward Nomination_FORM.cfm:
    > > line 414
    > > Called from
    > > C:\CFusionMX7\wwwroot\Awards\Forms\edit_GroupAward Nomination_FORM.cfm:
    > > line 1
    > >
    > > 412 : SELECT Project, FirstName, LastName
    > > 413 : FROM Nominations
    > > 414 : WHERE Project = "#SelectedProject#"
    > > 415 : </cfquery>
    > > 416 : <cfset counter = 0 />
    > >
    > > (Of course it works when I substitute the value of #SelectedProject# in
    > > the place of the variable. I just don't know how to the programming
    > > code substitute it in the WHERE statement so that it works.)
    > >
    > > As witnnessed by the following code line, my ColdFusion debugger
    > > somehow knows the properly parsed name of the project passed to the
    > > second page and even shows it in the WHERE statement:
    > >
    > > SQL SELECT Project, FirstName, LastName FROM Nominations
    > > WHERE Project = "<cfoutput>Fox River Team </span></cfoutput>"
    > >
    > > Why then am I getting the error?
    > >
    > > I have also tried, among other things,
    > > WHERE Project IN (<cfqueryparam cfsqltype="cf_sql_longvarchar"
    > > value="#SelectedProject#" list="yes" separator=",">)
    > > This does not result in an error, but in no results being displayed at
    > > all.
    > >
    > > Can you, would you help? Thanks.
    zdenek@gmail.com Guest

  4. #4

    Default Parsing a query of query with a variable value

    Try using single quotes in your WHERE clause instead of double.
    Unregistered Guest

Similar Threads

  1. Using variable in sql query
    By Jared@Itron in forum Coldfusion Database Access
    Replies: 1
    Last Post: January 19th, 03:04 PM
  2. Variable in database query?
    By walkeraj00 in forum Coldfusion Database Access
    Replies: 4
    Last Post: January 10th, 05:47 PM
  3. Query of Queries on query New type query
    By david_h in forum Coldfusion Database Access
    Replies: 2
    Last Post: May 6th, 08:55 PM
  4. Help with variable query?
    By Bukzor in forum Macromedia ColdFusion
    Replies: 4
    Last Post: March 31st, 08:53 PM
  5. Parsing MySQL query return
    By John in forum PHP Development
    Replies: 4
    Last Post: July 29th, 03:47 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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