Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Query used to work

    I have this one query it used to work in cfm 5.0 but now gives an error in cfm
    6.0 <b>The query is</b> <CFQUERY NAME='ParentOrganization'
    datasource='mydatasource'> SELECT Organizations.OrganizationName,
    LinkAdv.LinkAdvID, LinkAdv.Custom1, LinkAdv.DateCreated,LinkAdv.configID FROM
    LinkAdv INNER JOIN Organizations ON LinkAdv.OrgID = Organizations.OrgID WHERE
    LinkAdv.LinkAdvID = #GetParentID.Custom13# AND LinkAdv.StatusID = 'Approved'
    AND DesignatedPages NOT LIKE '%UNGREENBIZ%' AND (LinkAdv.configID = 14 or
    LinkAdv.configID = 12) <CFIF #ConfigIDGooD# is '14'>AND LinkAdvID NOT IN
    (#GetData.LinkAdvID#)</cfif> Order By Custom1 </CFQUERY> <b>I get this
    error</b> error Error Executing Database Query. [Macromedia][SQLServer JDBC
    Driver][SQLServer]Incorrect syntax near the keyword &amp;apos;AND&amp;apos;.
    The error occurred in
    D:\web\customers\greenbiz\includes\Refrence_OtherL inks.cfm: line 37 Called from
    D:\web\customers\greenbiz\reference\events_record. cfm: line 222 Called from
    D:\web\customers\greenbiz\includes\Refrence_OtherL inks.cfm: line 37 Called from
    D:\web\customers\greenbiz\reference\events_record. cfm: line 222 35 : AND
    (LinkAdv.configID = 14 36 : or LinkAdv.configID = 12) 37 : <CFIF
    #ConfigIDGooD# is '14'>AND LinkAdvID NOT IN (#GetData.LinkAdvID#)</cfif> 38 :
    Order By Custom1 39 : </CFQUERY>
    --------------------------------------------------------------------------------
    SQL SELECT Organizations.OrganizationName, LinkAdv.LinkAdvID,
    LinkAdv.Custom1, LinkAdv.DateCreated,LinkAdv.configID FROM LinkAdv INNER JOIN
    Organizations ON LinkAdv.OrgID = Organizations.OrgID WHERE LinkAdv.LinkAdvID =
    AND LinkAdv.StatusID = 'Approved' AND DesignatedPages NOT LIKE '%UNGREENBIZ%'
    AND (LinkAdv.configID = 14 or LinkAdv.configID = 12) Order By Custom1
    DATASOURCE sunmaster_new VENDORERRORCODE 156 SQLSTATE HY000 The sql
    looks right no??

    mikey999 Guest

  2. Similar Questions and Discussions

    1. How does the query cache work?
      Hi all, I'm experiencing a strange problem ( IMHO). query: SELECT SQL_CALC_FOUND_ROWS `a`.`id` AS `aanvraag_id`, `a`.`tijdstip`,...
    2. Query use to work on CF 4.5
      I'm getting the following error "No value given for one or more required parameters." However this worked on CF 4.5 but not on CF 6.1. Any ideas? ...
    3. Query by date doesn't work
      I'm using Informix 9.3, If I run the query in Informix it works, when I run the same query in ColdFusion I get a string to date conversion. I'm...
    4. Query dosen't work
      hi friends i have a question i make this on application.cfm <cfapplication sessionmanagement="yes" name="UniqueName" ClientManagement="No"...
    5. SQL/ASP.NET getting DATE to work in query
      I'm grabbing today's date with some ASP.net code: Dim Today As Date Today = Microsoft.VisualBasic.Today() I'm then trying to run a SQL query...
  3. #2

    Default Re: Query used to work

    I don't see anything wrong either, so you might troubleshoot by removing parts
    of the query, like the CFIF part, to see if you can isolate the exact phrase
    that is causing the error.

    Also, you might consider replacing

    AND (LinkAdv.configID = 14 or LinkAdv.configID = 12)
    with
    AND LinkAdv.configID IN (12, 14)

    as it may be a little more efficient, and/or readable. (There really isn't
    anything wrong with the way that you did it, though.)

    Phil

    paross1 Guest

  4. #3

    Default Re: Query used to work

    It should not make a difference, but try putting a space after each clause.
    Sometimes if you have

    Select ColumnFrom TableWhere Column = value

    You will get an error, now the driver should do this (replace a space for the
    CR) but maybe it's not.

    Ken

    The ScareCrow Guest

  5. #4

    Default Re: Query used to work

    I tried making the changes you two suggested but this did not fix this issue.
    Here is the web site page the error is happening on in case this shines any
    light on this
    [url]http://www.greenbiz.com/reference/events_record.cfm?LinkAdvID=63234[/url]

    mikey999 Guest

  6. #5

    Default Re: Query used to work

    My guess is that you need single quotes around the 12 and 14 in (LinkAdv.configID = 14
    or LinkAdv.configID = 12)

    Tulsa Guest

  7. #6

    Default Re: Query used to work

    I visited your link and looked at the error message. You have a problem here:
    LinkAdv.LinkAdvID = #GetParentID.Custom13# It looks to me like
    #GetParentID.Custom13# is null or blank.

    Attached is your query as it showed at the bottom of the error message. Notice
    where it says WHERE LinkAdv.LinkAdvID = AND. Fix #GetParentID.Custom13# and
    you will probably be OK.

    Phil



    SELECT Organizations.OrganizationName, LinkAdv.LinkAdvID, LinkAdv.Custom1,
    LinkAdv.DateCreated,LinkAdv.configID FROM LinkAdv INNER JOIN Organizations ON
    LinkAdv.OrgID = Organizations.OrgID WHERE LinkAdv.LinkAdvID = AND
    LinkAdv.StatusID = 'Approved' AND DesignatedPages NOT LIKE '%UNGREENBIZ%' AND
    LinkAdv.configID IN (12, 14) Order By Custom1

    paross1 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