query of queries inside cffunction

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

  1. #1

    Default query of queries inside cffunction

    Hi im trying to use the benifits of query of queries, but cannot get it to
    work...Im calling a cffunction inside a cfc (mx) from flash.mx here is my code:
    Thanx in advance

    <cffunction name="getmodel" access="remote" returnType="query">
    <cfargument name="maerke" type="string">
    <CFQUERY NAME="q_model" Datasource="2004printmore">
    SELECT id, model FROM model
    WHERE kategori = #maerke#
    </CFQUERY>
    <cfreturn q_model>
    </cffunction>

    <cffunction name="querymodel" access="remote" returnType="query">
    <cfargument name="id" type="string">
    <CFQUERY NAME="model_qq" dbtype="query">
    SELECT id, model FROM q_model
    WHERE model.id = #id#
    </CFQUERY>
    <cfreturn model_qq>
    </cffunction>

    JENS LYNET Guest

  2. Similar Questions and Discussions

    1. Need Help with Query of Queries
      I have the query "almost" there but I'm not sure exactly how to accomplish this. I need all recrods meeting the criteria from the AppliedLicense...
    2. query of queries with avg()
      cfmx 6.1 when i use avg() in a query of queries it rounds the results (actually rounds results down)...so i'm wondering if i am doing this...
    3. 2 queries to 1 query
      Hello, Can somebody help me to combine these two queries into one query. <cfquery datasource="#DATAS#" name="getMainNav"> SELECT * FROM...
    4. Query of Queries on query New type query
      In CF5 we have a page that creates a query, using queryNew and querySetCell and the like, we then used dbtype="query" and gave it's name so we could...
    5. Query of Queries?
      I have a table named therapists with a field named modalities which contains a comma delimited list of id #s. I need to loop through a list of...
  3. #2

    Default Re: query of queries inside cffunction

    well both WHERE clauses are missing quotes:

    WHERE kategori = '#maerke#'
    WHERE model.id = '#id#'

    and your second function's not getting a query passed into it. though i guess
    because you're not scoping your queries these are in the cfc's variables scope.


    PaulH Guest

  4. #3

    Default Re: query of queries inside cffunction

    Hi Paul I dont need the quotes, i tested that. But what do u mean 'second
    function's not getting a query passed into it'? As i read the doc u just need
    to use the name of the query that you want to query....

    JENS LYNET Guest

  5. #4

    Default Re: query of queries inside cffunction

    > <cffunction name="getmodel" access="remote" returnType="query">
    > <cfargument name="maerke" type="string">
    > <CFQUERY NAME="q_model" Datasource="2004printmore">
    Well you're creating this query in this function...


    > <cffunction name="querymodel" access="remote" returnType="query">
    > <cfargument name="id" type="string">
    > <CFQUERY NAME="model_qq" dbtype="query">
    > SELECT id, model FROM q_model

    .... But you're referring to it in this function.

    How does querymodel() know about what goes on in getmodel()?

    --

    Adam
    Adam Cameron Guest

  6. #5

    Default Re: query of queries inside cffunction

    your function arguments define those as "string".

    good practice says that your functions should be 100% isolated from each other
    & the application calling them. your second function isn't being passed a query
    for it to work on. something like this maybe:

    <!--- t.cfc --->
    <cfcomponent>
    <cffunction name="getData" output="No" returntype="query">
    <cfset var q="">
    <cfquery name="q" datasource="lab">
    SELECT uniText, uniLanguage
    FROM unicodeTest
    ORDER BY uniLanguage
    </cfquery>
    <cfreturn q>
    </cffunction>

    <cffunction name="getSomeData" output="No" returntype="query">
    <cfargument name="language" required="Yes" type="string">
    <cfargument name="q" required="Yes" type="query">
    <cfset var reQ="">
    <cfquery name="reQ" dbtype="query">
    SELECT uniText
    FROM arguments.q
    WHERE uniLanguage='#arguments.language#'
    </cfquery>
    <cfreturn reQ>
    </cffunction>
    </cfcomponent>

    <!--- t.cfm --->
    <cfscript>
    q=createObject("component","t");
    aQuery=q.getData();
    b=q.getSomeData("Arabic",aQuery);
    </cfscript>

    <cfdump var="#b#">

    PaulH 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