Create a function queryInsertRow()

Description

Introduce a new function queryInsertRow(qry:query to insert rows into, numberOrData, position) that allows inserting a record into a CFML query.

NumberOrData can be:
number: number of empty records to insert
struct: one record containing field:value pairs
arrayOfStructs: many records containing field:value pairs

Position: numeric, the number of the record before which the new records should be inserted. If the number is > recordCount, the records will be appended (similar to regular queryAddRow)


OR alternatively —

extend the current implementation of queryAddRow() with an additional last Parameter that indicates the position(s), the record(s) should be inserted.

Activity

Pothys - MitrahSoft 
3 December 2021 at 14:01

Now, The similar function queryInsertAt(query, value, index) was implemented in lucee 6.0. But It slightly different than described here. It allows a query, struct, or array as a value to insert into a query. Using query as a value we can insert multiple rows but using struct/array it inserts only one row on the given position.

https://github.com/lucee/Lucee/commit/6cbe32ed2e2473bd1c7d69d66406dcaf18247611

Former user 
2 February 2016 at 12:38

A 3rd optional argument works for me I guess - I still feel it's a bit nonsensical but can see where you would get use out of it + adding the extra argument I doubt would be that major

Gert Franz 
2 February 2016 at 11:47

For me that would be totally ok. As I proposed, either or.

Igal Sapir 
1 February 2016 at 16:56

we had a ticket for this in the old JIRA but a bit differently.

we have

queryAddRow(query, numberOrData)

I much rather add a 3rd optional argument so that it would become:

queryAddRow(query, numberOrData [, position])

Gert Franz 
1 February 2016 at 12:40

Pretty simple, because QoQ is a PITA and takes ages. Take the simple challenge where you can't apply a sorting algorithm to your query (like sums or whatever) but you need to insert sum rows to the query (for whatever reason). I know there are always ways to code around it, but the issue is mainly performance here.

Details

Assignee

Reporter

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Priority

Created 1 February 2016 at 10:21
Updated 4 October 2022 at 10:48