– Common Function Library Project

getRowFromQuery(qry, row)

Last updated June 21, 2014


Tony Felice

Version: 1 | Requires: CF5 | Library: DataManipulationLib

Given a numeric row id, this function will return the single row as a query object.

Return Values:
Returns a query.


<cfset myQuery = QueryNew("Name, Time, Advanced", "VarChar, Time, Bit")>
<cfset newRow = QueryAddRow(MyQuery, 2)>
<cfset QuerySetCell(myQuery, "Name", "The Wonderful World of CMFL", 1)>
<cfset QuerySetCell(myQuery, "Time", "9:15 AM", 1)>
<cfset QuerySetCell(myQuery, "Advanced", False, 1)>
<cfset QuerySetCell(myQuery, "Name", "CFCs for Enterprise Applications", 2)>
<cfset QuerySetCell(myQuery, "Time", "12:15 PM", 2)>
<cfset QuerySetCell(myQuery, "Advanced", True, 2)>

The second row of the query is: <cfdump var="#getRowFromQuery(myQuery,2)#">


Name Description Required
qry Query to inspect. Yes
row Numeric row to retrieve. Yes

Full UDF Source:

 * Return a single row from a query.
 * v1.0 by Tony Felice
 * v1.1 by Adam Cameron (changing name so as to not conflict with current CFML)
 * @param qry      Query to inspect. (Required)
 * @param row      Numeric row to retrieve. (Required)
 * @return Returns a query. 
 * @author Tony Felice ( 
 * @version 1.10, June 21, 2014 
function getRowFromQuery(qry,row){
    var result = queryNew('');
    var cols = listToArray(arguments.qry.columnList);
    var i = '';

    for(i=1; i lte arrayLen(cols); i=i+1){
        queryAddColumn(result, cols[i], listToArray(arguments.qry[cols[i]][arguments.row]));

    return result;


Latest Additions

Raymond Camden added
November 04, 2017

Leigh added
May 11, 2016

Raymond Camden added
May 10, 2016

Kevin Cotton added
May 05, 2016

Raymond Camden added
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson