Dave, As a side bar unless you have less than a few hundred rows this is HORRIBLY inefficient. You can improve performance a bit by using <cftransaction> and committing every 100 rows, but for any sizable database there are other, more effective ways to move the data.
Jonathan Works -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Phipps Sent: Wednesday, October 10, 2007 8:10 AM To: [email protected] Subject: Re: [Reactor for CF] Looping through query columns to set data Thanks Jonathan, I'll give it a try when I get 5 mins! Cheers, Dave Works, Jonathan G. wrote: > Something like this should work: > > <cfloop query="qNewProds"> > <cfset product = getReactorFactory().createRecord('products') /> > <cfloop list="#qNewProds.columnlist#" index="columnName"> > <cfset args = StructNew()/> > <cfset StructInsert(args, columnName, qNewProds[columnName]) > /> > <cfinvoke component="#products#" method="set#columnName#" > argumentcollection="#args#"> > </cfloop> > <cfset product.save() /> > </cfloop> > > > Jonathan Works > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of David Phipps > Sent: Wednesday, October 10, 2007 7:53 AM > To: [email protected] > Subject: [Reactor for CF] Looping through query columns to set data > > Hi, > > I am trying to save myself some typing and I have a query from a db that I > want to import into my "reactor managed" db. The query has quite a few > columns and I was hoping I could do something like this: > > <cfloop query="qNewProds"> > <cfset pr = getReactorFactory().createRecord('products') /> > <cfloop list="#qNewProds.columnlist#" index="i"> > <cfset variables[pr & '.set' & i](i) /> > </cfloop> > <cfset pr.save() /> > </cfloop> > > This is the line causing me problems: > > <cfset variables[pr & '.set' & i](i) /> > > What I want the above to do is the equivalent of this: > > <cfset pr.setColumnName(ColumnName) /> > > but using the columnlist to do it for each column in the query. > > Can someone point me in the right direction? > > Many thanks, > > Dave > -- > _______________________________________________________________________ > David Phipps, Director > [EMAIL PROTECTED] > > Chapel Studios / London > T +44 (0)20 7100 6980 F +44 (0)20 7100 6981 M +44 (0)7765 240899 > New Broad Street House, 35 New Broad Street, London, EC2M 1NH, UK > > Visit our website: http://www.chapel-studios.co.uk > > ______________________________________________________________________ > _ > > Chapel Studios is a limited company registered in England. The > information in this email is confidential, intended solely for the > addressee, and may be legally privileged. If you are not the addressee > or authorized to receive this for the addressee, you must not use, copy, > disclose or take any action based upon this message or any information > herein. If you have received this message in error, please advise > the sender immediately by reply e-mail. > > > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > -- -- -- -- Reactor for ColdFusion Mailing List [EMAIL PROTECTED] > Archives at: http://www.mail-archive.com/reactor%40doughughes.net/ > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > -- -- -- -- > > CONFIDENTIALITY NOTICE: This e-mail may contain information that is > privileged, confidential or otherwise protected from disclosure. If you are > not the intended recipient of this e-mail, please notify the sender > immediately by return e-mail, purge it and do not disseminate or copy it. > > > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > -- -- -- -- Reactor for ColdFusion Mailing List [EMAIL PROTECTED] > Archives at: http://www.mail-archive.com/reactor%40doughughes.net/ > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > -- -- -- -- > -- _______________________________________________________________________ David Phipps, Director [EMAIL PROTECTED] Chapel Studios / London T +44 (0)20 7100 6980 F +44 (0)20 7100 6981 M +44 (0)7765 240899 New Broad Street House, 35 New Broad Street, London, EC2M 1NH, UK Visit our website: http://www.chapel-studios.co.uk _______________________________________________________________________ Chapel Studios is a limited company registered in England. The information in this email is confidential, intended solely for the addressee, and may be legally privileged. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based upon this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Reactor for ColdFusion Mailing List [EMAIL PROTECTED] Archives at: http://www.mail-archive.com/reactor%40doughughes.net/ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- CONFIDENTIALITY NOTICE: This e-mail may contain information that is privileged, confidential or otherwise protected from disclosure. If you are not the intended recipient of this e-mail, please notify the sender immediately by return e-mail, purge it and do not disseminate or copy it. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Reactor for ColdFusion Mailing List [EMAIL PROTECTED] Archives at: http://www.mail-archive.com/reactor%40doughughes.net/ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
