Just to waste memory, doesn't make sense to me? Sorry Steve, what you did was great. But I don't see how adding 99 blank rows, with maybe 32 columns is beneficial to the memory you end up wasting.
We'll just end it there, I think. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 9015 8628 Mobile: 0404 998 273 -----Original Message----- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Steve Onnis Sent: Thursday, 15 May 2008 12:57 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: queryAddRow Ok qry = queryNew(""); queryAddColumn(qry, "fruit", listToArray("banana,apple,orange")); queryAddColumn(qry, "vegies", listToArray("carrot,cucumber,tomato")); ***** This query has 3 rows newRow = structNew(); newRow["fruit"] = "Test"; newRow["vegies"] = "Andrew"; qry = queryInsertRow( qry, 15, newRow); You want to insert the new record into the 15th row position but the query only has 3 rows in it. If you use arrayAppend() the new row would be inserted into the 4th position, not the 15th. As I said, the function covers you being able to do that, increase the row size of the query to what ever you want. You want an example? How about this. :: Users table :: Userid Name Email 1 Steve [EMAIL PROTECTED] 100 Andrew [EMAIL PROTECTED] Here we have a table with 2 rows but the IDs are not corrisponding to the actual id values <cfscript> qry = queryNew(""); queryAddColumn(qry, "UserID", listToArray("1,100")); queryAddColumn(qry, "Name", listToArray("Steve,Andrew")); queryAddColumn(qry, "Email", listToArray("[EMAIL PROTECTED],[EMAIL PROTECTED]")); </cfscript> <cfset newQry = queryNew(qry.columnList) /> <cfloop query="qry"> <cfset newRow = structNew() /> <cfloop list="#columnList#" index="c"> <cfset newRow[c] = qry[c][currentRow] /> </cfloop> <cfset newQry = queryInsertRow(newQry, UserID, newRow) /> </cfloop> Now each row of the query matches the userid value so if you wanted to you could now do <cfoutput>#newQry[userid].name#</cfoutput> This way you could extend the query like this and not have to QoQ to get the values for the user based on a userid. Keep in mind this is just an example and I am sure there are other times you may want to extend the query like this. Steve -----Original Message----- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Andrew Scott Sent: Thursday, 15 May 2008 12:35 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: queryAddRow Steve, That doesn't make sense to me, why would you need to call arrayAppend 12 times, when you have a condition like this? if (position GT query.recordCount) { That one line, is checking to see if it needs to go to the end of the query. I did also ask if it was your intention to insert at 10 elements above the size of the query, and why anyone would actually do that is beyond me. So my question stands, but of course I doubt you actually tried it with the arrayAppends. Here is your code output and underneath that is mine using ArrayAppend. I still don't understand why you want that many null records? Steves Code: ------------ query [long version] fruit vegies 1 banana carrot 2 apple cucumber 3 orange tomato 4 [null] [null] 5 [null] [null] 6 [null] [null] 7 [null] [null] 8 [null] [null] 9 [null] [null] 10 [null] [null] 11 [null] [null] 12 [null] [null] 13 [null] [null] 14 [null] [null] 15 [null] [null] 16 Test Andrew Query Source: QueryNew() ArrayAppend Code: ----------------- query [long version] fruit vegies 1 banana carrot 2 apple cucumber 3 orange tomato 4 Test Andrew Query Source: QueryNew() Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 9015 8628 Mobile: 0404 998 273 -----Original Message----- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Steve Onnis Sent: Thursday, 15 May 2008 12:25 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: queryAddRow The object is to insert a row into a recordset. It shouldn't matter where you insert it. My method creates a new query with the row in the right spot leaving the rest of the row empty if required. If you use arrayAppend() for your example, I would have to call arrayAppend() 12 times before I could set the array position of 15. Using arrayResize() I can resize the array in one go and just set the value of the array. Becoming clearer? -----Original Message----- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Andrew Scott Sent: Thursday, 15 May 2008 12:15 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: queryAddRow I should also add that with your method of not using ArrayAppend, creates empty records when doing this. Can you now see why I asked the original question? Or was that the desired effect you wanted? qry = queryNew(""); queryAddColumn(qry, "fruit", listToArray("banana,apple,orange")); queryAddColumn(qry, "vegies", listToArray("carrot,cucumber,tomato")); newRow = structNew(); newRow["fruit"] = "Test"; newRow["vegies"] = "Andrew"; qry = queryInsertRow( qry, 15, newRow); Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 9015 8628 Mobile: 0404 998 273 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "cfaussie" group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~----------~----~----~----~------~----~------~--~---