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

QueryInsertAt

Last update:
May 18, 2026

Description

Inserts an element into a query. Query elements whose indexes are equal to or greater than the new position are incremented by one.

Returns

Returns the updated query with the specified element inserted.

Category

Syntax

QueryInsertAt(query,value,position)
Member functions
queryObject.InsertAt(value,position)

See also

History

ColdFusion (2018 release) Update 5: Added the function.

Parameters

Parameter
Required/Optional
Description
query
Required
The query object where another query object is to be inserted.
value
Required
The query object to insert.
position
Required
Index position at which to insert the query object.

Example

<cfscript> 
 myQuery=queryNew("empid,depid,name", "integer,integer,varchar",[ 
    [10, 101, "John"], 
    [20, 120, "James"], 
    [30, 205, "Peter"] 
    ]); 
    writeOutput("Original query object is:" & "<br/>") 
    writeDump(myQuery) 
    // new query object 
    queryOneToBeInserted=queryNew("empid,depid,name", "integer,integer,varchar",[ 
     [15,110,"Alan"], 
     [16,115,"Jack"] 
    ]) 
    QueryInsertAt(myQuery,queryOneToBeInserted,2) 
    writeOutput("Query after insertion:" & "<br/>") 
    writeDump(myQuery) 
</cfscript>
Output
Query inserted
Member function
<cfscript> 
 myQuery=queryNew("empid,depid,name", "integer,integer,varchar",[ 
    [10, 101, "John"], 
    [20, 120, "James"], 
    [30, 205, "Peter"] 
    ]); 
    writeOutput("Original query object is:" & "<br/>") 
    writeDump(myQuery) 
    // new query object 
    queryOneToBeInserted=queryNew("empid,depid,name", "integer,integer,varchar",[ 
     [15,110,"Alan"], 
     [16,115,"Jack"] 
    ]) 
    myQuery.InsertAt(queryOneToBeInserted,2) 
    writeOutput("Query after insertion:" & "<br/>") 
    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