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

  1. #1

    Default trouble with dbtype

    <cfquery name="getIDs" datasource="#request.site.datasource#">
    SELECT DISTINCT f.ecrcomplianceid, f.ecractivityid, f.ecrcategoryid,
    subtaskid
    FROM uspsfat f, uspsecractivity a
    WHERE a.ecractivityid = f.ecractivityid and a.ecractivityid = #ID#
    </cfquery>

    <cfquery name="oaData" dbtype="query" datasource="#request.site.datasource#">
    SELECT a.* from uspsecractivity a, query.getIDs g
    WHERE a.ecractivityid = g.ecractivityid
    order by ecractivity
    </cfquery>
    This is the code I currently have, it isn't running at all, am I using the
    dbtype incorrectly? Any help would be appreciated.

    throm Guest

  2. Similar Questions and Discussions

    1. dbtype attribute does not support dynamic?
      I am going through all the code on my website because I am upgrading from CF 5 to CFMX 7 and I am validating markup using Dreamweaver MX keep...
    2. dbtype=query with like
      Has anyone been able to use LIKE in a select statement of a query of queries? Doing this causes an error: <cfquery name = "lastQuery" datasource...
    3. SQL database connection problem with dbtype="ODBC"
      I am having one website in coldfusion. But not able to connect database with application. I am getting following error. I created Database in...
    4. A big trouble
      Antonio Jose wrote: You should enable strict as well use strict; You do realize that arrays in perl start at zero and not one?
    5. VisualAge 6 installation trouble on aix 5.2, gcc trouble too :)
      I've installed gcc 3.x from UCLA site. and I got this error - In file included from test.c:23: /usr/include/pthread.h:554: error: parse error...
  3. #2

    Default Re: trouble with dbtype

    When doing a Q of Q, you don't want a datasource attribute in your cfquery tag.

    Originally posted by: throm
    <cfquery name="getIDs" datasource="#request.site.datasource#">
    SELECT DISTINCT f.ecrcomplianceid, f.ecractivityid, f.ecrcategoryid,
    subtaskid
    FROM uspsfat f, uspsecractivity a
    WHERE a.ecractivityid = f.ecractivityid and a.ecractivityid = #ID#
    </cfquery>

    <cfquery name="oaData" dbtype="query" datasource="#request.site.datasource#">
    SELECT a.* from uspsecractivity a, query.getIDs g
    WHERE a.ecractivityid = g.ecractivityid
    order by ecractivity
    </cfquery>
    This is the code I currently have, it isn't running at all, am I using the
    dbtype incorrectly? Any help would be appreciated.



    Dan Bracuk Guest

  4. #3

    Default Re: trouble with dbtype

    It isn't very clear at all from your post what you are actually attempting to
    accomplish. The query below does what appears like you are trying to do.

    <cfquery name="getIDs" datasource="#request.site.datasource#">
    SELECT DISTINCT a*, f.ecrcomplianceid, f.ecractivityid, f.ecrcategoryid,
    f.subtaskid
    FROM uspsfat f
    INNER JOIN uspsecractivity a ON a.ecractivityid = f.ecractivityid
    WHERE a.ecractivityid = #ID#
    </cfquery>

    Phil

    paross1 Guest

  5. #4

    Default Re: trouble with dbtype

    Sorry about the confusion, what I am trying to do is take the ID numbers I get
    from one table and use them to get connected columns from a different table.
    From what I can understand (which is not much I am pretty new to this query SQL
    thing) I need to have 2 different database queries then a final query that
    combines the two? This is the code I have right now, still not working. (Hope
    the comments make this a bit clearer)

    <!--- this query is to get all the different ecrID numbers related to #ID#
    --->
    <cfquery name="getIDs" datasource="#request.site.datasource#">
    SELECT DISTINCT f.ecrcomplianceid, f.ecractivityid, f.ecrcategoryid,
    subtaskid
    FROM uspsfat f, uspsecractivity a
    WHERE a.ecractivityid = f.ecractivityid and a.ecractivityid = #ID#
    </cfquery>

    <!--- these selects the entire ECR tables --->
    <cfquery name="getecractivity" datasource="#request.site.datasource#">
    SELECT *
    FROM uspsecractivity a
    </cfquery>

    <cfquery name="getecrcategory" datasource="#request.site.datasource#">
    SELECT *
    FROM uspsecrcategory
    </cfquery>

    <cfquery name="getecrcompliance" datasource="#request.site.datasource#">
    SELECT *
    FROM uspsecrcompliance
    </cfquery>

    <!--- this gets the columns related to the ID --->
    <cfquery name="oaData" dbtype="query">
    Select a.*
    from getecractivity a, getIDs i
    where a.ecractivityid = i.ecractivityid
    </cfquery>

    <cfquery name="gcData" dbtype="query">
    SELECT ca.*
    FROM getecrcategory ca, getIDs i
    WHERE ca.ecrcategoryid = i.ecrcategoryid
    order by ecrcategory
    </cfquery>

    <cfquery name="ciData" dbtype="query" datasource="#request.site.datasource#">
    SELECT co.*
    FROM getecrcompliance co, getIDs i
    WHERE co.ecrcomplianceid = i.ecrcomplianceid
    order by ecrcompliance
    </cfquery>


    throm Guest

  6. #5

    Default Re: trouble with dbtype

    I figured it out! Thanks for your time and help.
    throm Guest

  7. #6

    Default Re: trouble with dbtype

    Sorry, but it is still not clear at all. You can 'take the ID numbers I get
    from one table and use them to get connected columns from a different table"
    within a single query without having to use Q-of-Q or multiple queries, but you
    still haven't really said what specific ID numbers from which tables, etc.

    Q-of-Q is usually used to perform a secondary query on the result set from an
    original query, and I don't see that as what you are really trying to do. Can
    you explain, in English, what your database structure is, the relationships,
    and what particular data you are trying to end up with, and what you are trying
    to do with that data, etc.?

    Phil

    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