logo
down
shadow

How to remove row from CFLoop query results


How to remove row from CFLoop query results

By : Raphael Sousa
Date : November 16 2020, 06:23 AM
will be helpful for those in need OK, the model answer here is: do not do this in CFML, do it on the DB. CF is for string generation, not data manipulation.
The question is slightly misleading as it initially asks how to remove rows from the query, which - as it turns out - is not the requirement (see comments on the question). I have answered that question further down.
code :
<cfloop query="myquery">
    <cfif listfindnocase(myquery.setup_option,"required_information")>
        <cfquery name="someRecord" dbtype="query">
            select * from second_table
            where key_id = '#myquery.key_id#'
        </cfquery>
        <cfif someRecord.recordcount eq 0>
            <cfcontinue>
        </cfif>
        <!--- handle the rows you *do* want to process here --->
    </cfif>
</cfloop>
// pseudocode, for brevity
newQuery = queryNew(oldQuery.columnList)
loop (oldQuery)
    if the row is not wanted
        continue
    /if
    add a row to newQuery
    add the row data to newQuery
/loop
listOfRowsToExclude = someMechanismToArriveAtSaidList()
<cfquery name="newQuery" type="query">
    SELECT   *
    FROM     oldQuery
    WHERE    id NOT IN (listOfRowsToExclude)
    ORDER BY [same clause as for oldQuery]
</cfquery>


Share : facebook icon twitter icon
how to run cfloop on struct results in coldfusion

how to run cfloop on struct results in coldfusion


By : ta69am
Date : March 29 2020, 07:55 AM
will help you Based on the updates that you have made to your question it looks like you might need to do something like this:
code :
<cfoutput>
  <cfloop query="categoryList.results"> 
     <p>#id# - #name# - #type# </p>
  </cfloop>
</cfoutput>
Using cfthread inside cfloop results in random output

Using cfthread inside cfloop results in random output


By : Rajesh
Date : March 29 2020, 07:55 AM
hope this fix your issue Probably need a bit more as Adam said.
If there is an "end result" you are looking for here, where your "final PDF" is dependent on the work being done by the loop/thread code, the the code above is going to give you inconsistent & unpredictable results.
populate array using cfloop query

populate array using cfloop query


By : aminaminamin
Date : March 29 2020, 07:55 AM
hop of those help? Unless you actually need the index for something else, just omit it and use ArrayApend which "... Appends an array element to the end of a specified array".
code :
 <cfset ArrayAppend( MyArray, GetPermission.Permission_ID)>
cfloop and query of queries

cfloop and query of queries


By : Arnold Detkov
Date : March 29 2020, 07:55 AM
should help you out I have a scenario like below on a page. I have a query being returned from a cfc all_data which has columns, section, state, data. Now the page design looks something like below. , I think you can use the group attribute as below
code :
<cfset myQuery = QueryNew("Section, State, Data", "VarChar, VarChar, VarChar")> 

<cfset newRow = QueryAddRow(MyQuery, 5)> 

<!--- Set the values of the cells in the query ---> 
<cfset temp = QuerySetCell(myQuery, "Section", "Section 1", 1)> 
<cfset temp = QuerySetCell(myQuery, "State", "State 1", 1)> 
<cfset temp = QuerySetCell(myQuery, "Data", "Data 1", 1)> 
<cfset temp = QuerySetCell(myQuery, "Section", "Section 1", 2)> 
<cfset temp = QuerySetCell(myQuery, "State", "State 2", 2)> 
<cfset temp = QuerySetCell(myQuery, "Data", "Data 2", 2)> 
<cfset temp = QuerySetCell(myQuery, "Section", "Section 1", 3)> 
<cfset temp = QuerySetCell(myQuery, "State", "State 2", 3)> 
<cfset temp = QuerySetCell(myQuery, "Data", "Data 3", 3)> 
<cfset temp = QuerySetCell(myQuery, "Section", "Section 2", 4)> 
<cfset temp = QuerySetCell(myQuery, "State", "State 2", 4)> 
<cfset temp = QuerySetCell(myQuery, "Data", "Data 2", 4)> 
<cfset temp = QuerySetCell(myQuery, "Section", "Section 2", 5)> 
<cfset temp = QuerySetCell(myQuery, "State", "State 2", 5)> 
<cfset temp = QuerySetCell(myQuery, "Data", "Data 3", 5)> 

 <cfoutput query ="myQuery" group="Section">
    </br>#Section# <!--- You will get distinct Sections here --->
    <cfoutput group="Section">
            </br>#State#,
            <cfoutput>#Data#,</cfoutput>
    </cfoutput>
 </cfoutput>
ColdFusion10 - query cfloop over an insert query

ColdFusion10 - query cfloop over an insert query


By : Mateo Zuluaga
Date : March 29 2020, 07:55 AM
hope this fix your issue One issue is you have a syntax error in your cfset statements. In cfset you need to use = instead of EQ.
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org