Solved

COLDFUSION GENERATE RECORDS FROM QUERY

Posted on 2007-04-02
4
165 Views
Last Modified: 2013-12-16
I have a table with following data:
Lot - Start_Number - End_Number - Value
100 - 1                   - 50                  - 3
200 - 101               - 250                - 5
300 - 501              - 750                - 8
And i need to generate the records from each one of the lines up to the end number. The result has to insert into my DB records like this:
Lot - Secuence-Value
100 - 1 - 3
100 - 2 - 3
100 - 3 - 3... and so on until secuence is = end_number and then go to next line and generate...
200 - 101 - 5
200 - 102 - 5
200 - 103 - 5 and so on...
Thanks
WmV
0
Comment
Question by:wvalencia
  • 3
4 Comments
 
LVL 5

Accepted Solution

by:
rucky544 earned 200 total points
ID: 18842503
<cfloop query="queryname">
  <cfloop from="Start_number" to="End_Number" index="index">
     <cfquery name="insert_data" datasource="yourDSN">
        insert into yourtablename (lot, secuence, value)
        values (#lot#, #index#, #value#)
     </cfquery>
   </cfloop>
</cfloop>
0
 
LVL 5

Expert Comment

by:rucky544
ID: 18842513
It loops over the query, then loops from the start number to the end number and inserts a row for each one, index is the values beween start and end numbers.

That should work for you
0
 
LVL 39

Assisted Solution

by:gdemaria
gdemaria earned 50 total points
ID: 18844952

 Small type-o, don't forget the #'s in the loop..

<cfloop from="#Start_number#" to="#End_Number#" index="index">


 (no points pls)
0
 
LVL 5

Expert Comment

by:rucky544
ID: 18846548
oh yeah thanks for spotting that gdemaria
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Now that Expression Web 4.0 (http://www.microsoft.com/expression/products/Upgrade.aspx) is free if you buy or have the full version of Expression Web 3.0, now is the best time to  migrate from FrontPage to Expression Web (http://www.frontpage-to-exp…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now