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

QueryRowSwap

Last update:
May 18, 2026

Description

Swaps the contents of a row with a specified row in a query object.
For example, you can swap a record in sourceRow with the record of destinationRow.

Returns

A query object.

Category

Syntax

QueryRowSwap(query, sourceRow, destinationRow)
Member function
query.Swap(sourceRow, destinationRow)

History

New in ColdFusion (2018 release) Update 5.

Parameters

Parameter
Required/Optional
Description
Query
Required
The query object where the rows are to be swapped.
sourceRow
Required
The row to swap.
destinationRow
Required
The row to be swapped with.

See also

Example

<cfscript>
 myQuery1=queryNew("empid,depid,name", "integer,integer,varchar",[
    [10, 101, "John"],
    [20, 120, "James"],
    [30, 205, "Peter"]
    ]);
 myQuery2=queryNew("empid,depid,name","integer,integer,varchar",[
 [40, 530, "Jacob"],
    [50, 306, "Mary"],
    [60, 120, "Helen"]
 ])
 QueryAppend(myquery1,myquery2)
 WriteOutput("Query object before swap")
 WriteDump(myquery1)
 swapped=QueryRowSwap(myquery1,2,3) // Swap the records in position 2 and 3
 WriteOutput("Query object after swapping rows 2 and 3")
 WriteDump(swapped)
</cfscript>

Output

Query object before swap
Query object after swapping rows 2 and 3

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