Adobe Dreamweaver Forums



Last 10 THreads :         screen readable output (section 508) (Last Post : Colum McAndrew - Replies : 3 - Views : 4 )           »          Load content in order (Last Post : lammspillning - Replies : 12 - Views : 13 )           »          Re: Contribute 3: Could not connect because the serveris down or not acceptiong connections. (Last Post : Dominic Michael - Replies : 0 - Views : 1 )           »          Backup Best Practices (Last Post : Dominic Michael - Replies : 1 - Views : 5 )           »          Working Directory (Last Post : SujitG - Replies : 1 - Views : 2 )           »          get current URL (Last Post : aneuryzma - Replies : 0 - Views : 1 )           »          svn:ignore? (Last Post : David Powers - Replies : 8 - Views : 9 )           »          How to build Star War style captions (Last Post : Karl_Sigiscar_1971 - Replies : 1 - Views : 2 )           »          Alignment woes (Last Post : SujitG - Replies : 1 - Views : 2 )           »          Flash connecting to database, loading pictures (Last Post : NickPick1 - Replies : 0 - Views : 1 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Cold Fusion
 
Tags: , ,



Reply
  #1 (permalink)  
Old 07-23-2008, 06:08 PM
Steve Miller
 
Posts: n/a
Diggs:
Default Insert Query Results

Hello - What is the best method to take the results of a query that
returns a series of records based on an order number (ex. Order Number
is 1234ABC and returns 5 records that include sku, qty and price) and
insert the query results into a db table?

Any help is appreciated.

Thanks,
Steve


Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-23-2008, 07:13 PM
Magikaru
 
Posts: n/a
Diggs:
Default Re: Insert Query Results

First, do a cfloop over your first query. Inside the loop, have a query that
will insert info into the other table one row at a time.

ex:

<cfloop query="firstQuery">
<cfquery name="insertionQuery" datasource="someDatasource">
insert into mytable (Order_Number, sku, qty, price)
values ('#Order_Number#','#sku#',#qty#,#price#)
</cfquery>
</cfloop>

Reply With Quote
  #3 (permalink)  
Old 07-24-2008, 02:23 PM
ncvoss@gmail.com
 
Posts: n/a
Diggs:
Default Re: Insert Query Results

You should be able to do this entirely within your sql statement too
which would be less intensive on the cf server and faster to execute
(fewer connections to the DB):

<cfquery datasource="mydsn" name="insertRows">
INSERT INTO mytable(mycol1, mycol2, mycol3, mycol4)
SELECT mycol1,mycol2,mycol3,mycol4 FROM otherTable WHERE myCriteria =
true
</cfquery>

Nick
Reply With Quote


Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 11:17 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk