Whatever message this page gives is out now! Go check it out!

QueryGetRow

Last update:
May 18, 2026

Description

This function returns a struct that has all the columns as keys and their corresponding values.

Returns

Struct

Category

Syntax

QueryGetRow(query, rowNum)

History

ColdFusion (2018 release): Introduced named parameters.
Introduced in ColdFusion 11.

Parameters

Parameter
Description
query
The query object to get data from.
rowNum
The position of the row.

Example

<cfscript>
       myQuery=QueryNew("ID,Name,Rating","integer,varchar,double");
       myFirstData=StructNew();
       myFirstData={ID=1,Name="Nixon",Rating=56.87};
       QueryAddRow(myQuery,myFirstData);
       WriteOutput("Recordset updated with struct data:");
       WriteDump(myQuery);
       myGet=QueryGetRow(myQuery,1);
       WriteOutput("Returns struct with columns as keys:");
       WriteDump(myGet);
       //Try to return struct values for row=2 that does not exist
       try{
             QueryGetRow(myQuery,2);
       }
       catch(any q){
             WriteOutput(q.message);// Displays appropriate message
       }
</cfscript>

Output

Using member function

<cfscript>
       myQuery=QueryNew("ID,Name,Rating","integer,varchar,double");
       myFirstData=StructNew();
       myFirstData={ID=1,Name="Nixon",Rating=56.87};
       QueryAddRow(myQuery,myFirstData);
       myRow=myQuery.getRow(1);
       WriteDump(myQuery);
</cfscript>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page