COLDFUSION GENERATE RECORDS FROM QUERY

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
wvalenciaAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
rucky544Connect With a Mentor Commented:
<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
 
rucky544Commented:
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
 
gdemariaConnect With a Mentor Commented:

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

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


 (no points pls)
0
 
rucky544Commented:
oh yeah thanks for spotting that gdemaria
0
All Courses

From novice to tech pro — start learning today.