CFScript Math expression - Summing up looped over data

If I loop over numeric data and  I want to sum that data I am looking for the correct manner to do so. Of course I want to do this in cfscript.
I know that I could go the route of doing a one demensional array and using the array sum function and I could also use stauctures.
I am interested in different solutions to this problem.
My end state is that I need to sum and average looped dynamic data for reporting purposes.
For purposes of example static values will be helpful for better understanding.
Thanks in advance.

Owain,
This is what I came up with and it outputs the looped data. Now I am trying to add it up and average the results.
BTW Adam,
Be delusional on a Microsoft or Oracle forum board.
Now that would be some fun reading cutting through those flames! (In a patronising Kinda Way!).

Similar Messages

  • Loop over data

    I have returned a dataset and one of the fields from the
    dataset is a comma delimited list, is there a way to loop over this
    list and display the values.

    Hi Martin,
    you assign the VARC incorrectly.
    L_ACC = VARC(VACVTE01).
    should be
    L_OBSERV = VARC(VACVTE01).
    Regards,
    Marc
    SAP NetWeaver RIG

  • Looping over arraycollection with sap data

    Hello,
    I asked a lot of persons but i still have a problem.
    I am trying to make a organizational chart in Adobe Flex with data out of the SAP system.
    When I try to access my data that I have given trough the Flash Islands container it doesn’t work.
    I do:
    [Bindable]
    Public var datasource:Arraycollection;
    Then I want to loop over this datasource with a for loop but it says that the object is null.
    for (i = o; i < datasource.length; i++)
    When I use datasource as dataprovider for a datagrid in Flex, that works perfect.
    Please answer fast because I need it for school.
    greetings

    Hello,
    I asked a lot of persons but i still have a problem.
    I am trying to make a organizational chart in Adobe Flex with data out of the SAP system.
    When I try to access my data that I have given trough the Flash Islands container it doesn’t work.
    I do:
    [Bindable]
    Public var datasource:Arraycollection;
    Then I want to loop over this datasource with a for loop but it says that the object is null.
    for (i = o; i < datasource.length; i++)
    When I use datasource as dataprovider for a datagrid in Flex, that works perfect.
    Please answer fast because I need it for school.
    greetings

  • Looping through date column - Summing hours per day

    All,
    Running the query below against my timesheet tables I get the following results:
    -----SQL CODE------
    SELECT
    ts.ts_date Date,
    ts.user_name Name,
    tc.account Account,
    ts.no_of_hrs Hours,
    SUM(ts.no_of_hrs) OVER(PARTITION BY ts.ts_date) Daily_Total
    FROM
    eba_time_timesheet ts,
    eba_time_timecodes tc
    WHERE
    ts.timecode_id = tc.id AND
    ts.user_name LIKE 'JohnD'
    ORDER BY
    1
    -----RESULTS-------
    Date          Name          Account     Hours     Daily Total
    1-Dec-09     JOHND          489310          1.5     8
    1-Dec-09     JOHND          486830          1.5     8
    1-Dec-09     JOHND          481710          3     8
    1-Dec-09     JOHND          481210          0.5     8
    1-Dec-09     JOHND          486840          0.5     8
    1-Dec-09     JOHND          485710          0.5     8
    1-Dec-09     JOHND          481010          0.5     8
    2-Dec-09     JOHND          481710          1     8
    2-Dec-09     JOHND          485710          7     8
    3-Dec-09     JOHND          481710          6     8
    3-Dec-09     JOHND          488810          1.5     8
    3-Dec-09     JOHND          481310          0.5     8
    4-Dec-09     JOHND          489710          8     8
    7-Dec-09     JOHND          481110          0.5     8
    7-Dec-09     JOHND          489710          7     8
    7-Dec-09     JOHND          481210          0.5     8
    However, I would prefer the Daily Total column be a row in the results instead of a column. Here is an example of how I would prefer the results. This statement will then be sent to a calendar for each user to see there time for each account and total time per day.
    Date          Name          Account     Hours
    1-Dec-09     JOHND          489310          1.5     
    1-Dec-09     JOHND          486830          1.5     
    1-Dec-09     JOHND          481710          3     
    1-Dec-09     JOHND          481210          0.5     
    1-Dec-09     JOHND          486840          0.5     
    1-Dec-09     JOHND          485710          0.5     
    1-Dec-09     JOHND          481010          0.5     
    *1-Dec-09     JOHND          Daily Total     8*
    2-Dec-09     JOHND          481710          1     
    2-Dec-09     JOHND          485710          7
    *2-Dec-09     JOHND          Daily Total     8*
    3-Dec-09     JOHND          481710          6     
    3-Dec-09     JOHND          488810          1.5     
    3-Dec-09     JOHND          481310          0.5
    *3-Dec-09     JOHND          Daily Total     8*
    4-Dec-09     JOHND          489710          8
    *4-Dec-09     JOHND          Daily Total     8*
    7-Dec-09     JOHND          481110          0.5     
    7-Dec-09     JOHND          489710          7     
    7-Dec-09     JOHND          481210          0.5
    *7-Dec-09     JOHND          Daily Total     8*
    Any help would be greatly appreciated.
    This is my 1st post so if I've left something out or you need additional info please let me know.
    I’m using Oracle 10g

    user9160575 wrote:
    Thanks for all the input! I ended up using the GROUP BY ROLLUP and adding a CASE statement for inserting "DAILY TOTAL" in the account column.If you are on at least 10g, model solution could be simpler:
    with t as (
               select to_date('1-Dec-09','dd-mon-yy') dt,'JOHND' name,489310 account,1.5 hours,8 daily_total from dual union all
               select to_date('1-Dec-09','dd-mon-yy'),'JOHND',486830,1.5,8 from dual union all
               select to_date('1-Dec-09','dd-mon-yy'),'JOHND',481710,3,8 from dual union all
               select to_date('1-Dec-09','dd-mon-yy'),'JOHND',481210,0.5,8 from dual union all
               select to_date('1-Dec-09','dd-mon-yy'),'JOHND',486840,0.5,8 from dual union all
               select to_date('1-Dec-09','dd-mon-yy'),'JOHND',485710,0.5,8 from dual union all
               select to_date('1-Dec-09','dd-mon-yy'),'JOHND',481010,0.5,8 from dual union all
               select to_date('2-Dec-09','dd-mon-yy'),'JOHND',481710,1,8 from dual union all
               select to_date('2-Dec-09','dd-mon-yy'),'JOHND',485710,7,8 from dual union all
               select to_date('3-Dec-09','dd-mon-yy'),'JOHND',481710,6,8 from dual union all
               select to_date('3-Dec-09','dd-mon-yy'),'JOHND',488810,1.5,8 from dual union all
               select to_date('3-Dec-09','dd-mon-yy'),'JOHND',481310,0.5,8 from dual union all
               select to_date('4-Dec-09','dd-mon-yy'),'JOHND',489710,8,8 from dual union all
               select to_date('7-Dec-09','dd-mon-yy'),'JOHND',481110,0.5,8 from dual union all
               select to_date('7-Dec-09','dd-mon-yy'),'JOHND',489710,7,8 from dual union all
               select to_date('7-Dec-09','dd-mon-yy'),'JOHND',481210,0.5,8 from dual
    select  dt "Date",
            name "Name",
            account "Account",
            hours "Hours"
      from  t
      model
        dimension by(dt,name,to_char(account) account)
        measures(hours,daily_total,0 seq)
        rules upsert all(
                         hours[any,any,'Daily Total'] = max(daily_total)[cv(dt),cv(name),any],
                         seq[any,any,'Daily Total'] = 1
      order by dt,
               name,
               seq,
               account
    Date      Name  Account                                       Hours
    01-DEC-09 JOHND 481010                                           .5
    01-DEC-09 JOHND 481210                                           .5
    01-DEC-09 JOHND 481710                                            3
    01-DEC-09 JOHND 485710                                           .5
    01-DEC-09 JOHND 486830                                          1.5
    01-DEC-09 JOHND 486840                                           .5
    01-DEC-09 JOHND 489310                                          1.5
    01-DEC-09 JOHND Daily Total                                       8
    02-DEC-09 JOHND 481710                                            1
    02-DEC-09 JOHND 485710                                            7
    02-DEC-09 JOHND Daily Total                                       8
    Date      Name  Account                                       Hours
    03-DEC-09 JOHND 481310                                           .5
    03-DEC-09 JOHND 481710                                            6
    03-DEC-09 JOHND 488810                                          1.5
    03-DEC-09 JOHND Daily Total                                       8
    04-DEC-09 JOHND 489710                                            8
    04-DEC-09 JOHND Daily Total                                       8
    07-DEC-09 JOHND 481110                                           .5
    07-DEC-09 JOHND 481210                                           .5
    07-DEC-09 JOHND 489710                                            7
    07-DEC-09 JOHND Daily Total                                       8
    21 rows selected.
    SQL> SY.

  • Need help with Expressions to get the sum of rows between dates

     Date              Total
    8/06/2010     $2000
    8/10/2010    $5000
    8/28/2010      $2500
    9/10/2010    $5000
    9/16/2010   $2000
    9/25/2010   $7000
    9/28/2010     $2500
    I need sum of rows based on month. I have tried  following syntax. It did not work, which is returning $0.  Appreciate any help i get.
    =sum(iif(Date.value>="8/01/2010" AND Date.value<="8/30/2010",Total.value,0))

    Hi RG K,
    According to your description, you want to calculate sum of total based on month use expression, but the expression does not work. If that is the case, please refer to the following steps:
    In design surface, right-click Insert and click Text Box.
    Right-click inside of the text box, then click expression.
    In Expression text box, type the expression like below:
    =sum(iif(Fields!Date.Value>="8/01/2010" AND Fields!Date.Value<="8/30/2010",Fields!total.Value,CDec(0)))
    In this expression, the data type of total is Decimal, so we need to convert 0 to Decimal use CDec() function. If data type of total is Double, we need to use CDbl() function.
    The following screenshot is for your reference:
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    Wendy Fu
    TechNet Community Support

  • [Solved] Foreach loop that loops over all files in a folder does not consider first file found

    Hello,
    I have a foreach loop in SSIS (as part of Visual Studio 10 and with SQL Server 2012).
    It loops over all files in a folder (ForEach File Enumerator).
    I set the folder: OK
    Traverse Sub folders: OK
    I have set up a Variable in Variable Mappings called FileName so it shows User::FileName: OK
    Index of variable is 0: OK
    It almost works ok. Except that the first file it finds is never considered.
    I set a breakpoint then and the first file it finds, is shown in black in the watch variable window. All subsequent files found are shown in red font. When I change the names of the files so another file is the first file found then it skips the other one
    which now is the first file.
    What is going on here? Why does SSIS skip the first file it finds in a foreach file loop?
    Any suggestions highly appreciated.
    Thank you
    Andi
    Andreas

    "red font - interesting, any example to show us (image)
    It would be interesting to share with us whether you use any file masks or expressions.
    Arthur
    MyBlog
    Twitter
    It appears a variable value turns red when it changes between breakpoints. It started black for the first value (the first file, obtained BEFORE the execution reached the breakpoint), and then turned red. I was able to reproduce this behavior on a test environment.
    However, it did not skip any files.
    OP, please set up the test shown in the image below. Create a breakpoint in the sequence container for the "OnPreExecute" event.

  • Problem with Message-Mapping: Loop over Elements possible?

    Hi all,
    I want do create a Message-Mapping for an IDoc-to-File Scenario. In the Source Structure there are some Elements which can appear more than once (1..unbounded). I need a mechanism which loops over these elements and search for specified values. From the Element which contains an element with this specified value the mapping should write a value in the target structure.
    Here a simple example (source structure) for better understanding:
    <root>
       <invoice>
          <number> 10 </number>
          <sum> 200.00 </sum>
       </invoice>
       <invoice>
          <number> 20 </number>
          <sum> 150.00 </sum>
       </invoice>
       <invoice>
          <number> 30 </number>
          <sum> 120.00 </sum>
       </invoice>
    </root>
    Now the duty of the Mapping should be to search in the elements <invoice> for the number 30. And then the sum of the invoice with the number 30 should be written in a field of the target structure.
    I tried it out with a constant togehter with an equalsS-function and an ifWithoutElse-function, but it is working only then, if the invoice with the number 30 has the first position in the root context.
    Can anybody help me? Thanks
    With kind regards
    Christopher

    Hi,
    Write a UDF to sum the required values and map to target node.
    See while writing the UDF select the type as queue.
    number -- removecontext-UDF targetnode
    sum----removecontext--/
    number abd sum or the two inputs
    in UDF
    int nsum = 0;
    for(int i;i < number.length;i++){
      if number(i).equals("30") then
         nsum = nsum + valueOf(sum(i));
    result.addValue(nsum); // convert the nsum into string
    Regsrds
    Chilla

  • [svn:fx-trunk] 11530: Fix ASC-3790 ( conditional expression in for loop causes verifier error) r=jodyer

    Revision: 11530
    Author:   [email protected]
    Date:     2009-11-06 13:23:05 -0800 (Fri, 06 Nov 2009)
    Log Message:
    Fix ASC-3790 (conditional expression in for loop causes verifier error) r=jodyer
    Ticket Links:
        http://bugs.adobe.com/jira/browse/ASC-3790
    Modified Paths:
        flex/sdk/trunk/modules/asc/src/java/macromedia/asc/parser/ConditionalExpressionNode.java

  • Why optimizer prefers nested loop over hash join?

    What do I look for if I want to find out why the server prefers a nested loop over hash join?
    The server is 10.2.0.4.0.
    The query is:
    SELECT p.*
        FROM t1 p, t2 d
        WHERE d.emplid = p.id_psoft
          AND p.flag_processed = 'N'
          AND p.desc_pool = :b1
          AND NOT d.name LIKE '%DUPLICATE%'
          AND ROWNUM < 2tkprof output is:
    Production
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.01       0.00          0          0          4           0
    Execute      1      0.00       0.01          0          4          0           0
    Fetch        1    228.83     223.48          0    4264533          0           1
    total        3    228.84     223.50          0    4264537          4           1
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 108  (SANJEEV)
    Rows     Row Source Operation
          1  COUNT STOPKEY (cr=4264533 pr=0 pw=0 time=223484076 us)
          1   NESTED LOOPS  (cr=4264533 pr=0 pw=0 time=223484031 us)
      10401    TABLE ACCESS FULL T1 (cr=192 pr=0 pw=0 time=228969 us)
          1    TABLE ACCESS FULL T2 (cr=4264341 pr=0 pw=0 time=223182508 us)Development
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.01       0.00          0          0          0           0
    Execute      1      0.00       0.01          0          4          0           0
    Fetch        1      0.05       0.03          0        512          0           1
    total        3      0.06       0.06          0        516          0           1
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 113  (SANJEEV)
    Rows     Row Source Operation
          1  COUNT STOPKEY (cr=512 pr=0 pw=0 time=38876 us)
          1   HASH JOIN  (cr=512 pr=0 pw=0 time=38846 us)
         51    TABLE ACCESS FULL T2 (cr=492 pr=0 pw=0 time=30230 us)
        861    TABLE ACCESS FULL T1 (cr=20 pr=0 pw=0 time=2746 us)

    sanjeevchauhan wrote:
    What do I look for if I want to find out why the server prefers a nested loop over hash join?
    The server is 10.2.0.4.0.
    The query is:
    SELECT p.*
    FROM t1 p, t2 d
    WHERE d.emplid = p.id_psoft
    AND p.flag_processed = 'N'
    AND p.desc_pool = :b1
    AND NOT d.name LIKE '%DUPLICATE%'
    AND ROWNUM < 2
    You've got already some suggestions, but the most straightforward way is to run the unhinted statement in both environments and then force the join and access methods you would like to see using hints, in your case probably "USE_HASH(P D)" in your production environment and "FULL(P) FULL(D) USE_NL(P D)" in your development environment should be sufficient to see the costs and estimates returned by the optimizer when using the alternate access and join patterns.
    This give you a first indication why the optimizer thinks that the chosen access path seems to be cheaper than the obviously less efficient plan selected in production.
    As already mentioned by Hemant using bind variables complicates things a bit since EXPLAIN PLAN is not reliable due to bind variable peeking performed when executing the statement, but not when explaining.
    Since you're already on 10g you can get the actual execution plan used for all four variants using DBMS_XPLAN.DISPLAY_CURSOR which tells you more than the TKPROF output in the "Row Source Operation" section regarding the estimates and costs assigned.
    Of course the result of your whole exercise might be highly dependent on the actual bind variable value used.
    By the way, your statement is questionable in principle since you're querying for the first row of an indeterministic result set. It's not deterministic since you've defined no particular order so depending on the way Oracle executes the statement and the physical storage of your data this query might return different results on different runs.
    This is either an indication of a bad design (If the query is supposed to return exactly one row then you don't need the ROWNUM restriction) or an incorrect attempt of a Top 1 query which requires you to specify somehow an order, either by adding a ORDER BY to the statement and wrapping it into an inline view, or e.g. using some analytic functions that allow you specify a RANK by a defined ORDER.
    This is an example of how a deterministic Top N query could look like:
    SELECT
    FROM
    SELECT p.*
        FROM t1 p, t2 d
        WHERE d.emplid = p.id_psoft
          AND p.flag_processed = 'N'
          AND p.desc_pool = :b1
          AND NOT d.name LIKE '%DUPLICATE%'
    ORDER BY <order_criteria>
    WHERE ROWNUM <= 1;Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Looping over QoQ Where Clause

    I have two queries. One is a main query that we pull from a form submission. The second is a small query resultset that lists different subgroups in my company and what main group they belong to. I pull several QoQ from the main query. In the main query results, there is a column that holds the subgroup information. I am trying to do a Q0Q where I group the data from the main query into the main groups for analysis. Here is an example...
    Main Query
    record 1 - subgroup 1
    record 2 - subgroup 2
    record 3 - subgroup 3
    Second Query
    Subgroup 1 - Main Group 1
    Subgroup 2 - Main Group 2
    Subgroup 3 - Main Group 1
    So I am trying to loop over a QoQ on the main query where the result set would contain the information only from Main Group 1. So record 2 would be eliminated. I have tried using an IN clause with a cfloop, but I run into syntax trouble with the comma. I also tried looping over the QoQ as a whole and the resulting dump is only the last record.
    If there is anything else you need, let me know.
    Any thoughts?
    Clay
    P.S. Here is a code sampling...
        <cfquery name="rsGroup" datasource="nps">
        SELECT *
        FROM "GROUP"
        WHERE GROUP.PrimaryGroup = '#form.primarygroup#'
        </cfquery>
        rsGroup - <cfdump var="#rsGroup#">
        <cfloop query="rsGroup" startrow="1" endrow="#rsGroup.RecordCount#">
            <cfquery name="rsGroupQoQ" dbtype="query">
            SELECT *
            FROM rsNPS
            WHERE rsNPS.grp = '#rsGroup.group#'
            </cfquery>
        </cfloop>
        rsGroupQoQ - <cfdump var="#rsGroupQoQ#"><cfabort>

    ok...I figured it out. I thought I would post my solution in case anyone else runs into this. Also, if anyone out there has a better way, let me know.
    <!---Dummy array to house 'blank' value for adding of column to main query--->
    <cfset GroupArray = ArrayNew(1)>
    <!---Variable that adds mainGroup column to main query with blank data from dummy array--->
    <cfset addMainGroup = QueryAddColumn(rsNPS,'mainGroup',GroupArray)>
    <!---Loop that sets value on added mainGroup column based off of main query grp column value--->
    <cfloop query="rsNPS" startrow="1" endrow="#rsNPS.RecordCount#">
        <cfif rsNPS.GRP EQ "xxxxx"><cfset rsNPS.mainGroup = "yyyyy"></cfif>
        <cfif rsNPS.GRP EQ "xxxxxxxxxx"><cfset rsNPS.mainGroup = "yyyyyyyyyy"></cfif>
        <cfif ...etc. ...
    </cfloop>

  • Efficient looping over strings

    ABAPers,
    I need to loop over all the characters in a string. Here is the pseudo code:
    data: myData TYPE string.
    data: n TYPE i.
    data: ch TYPE char1.
    n = STRLEN( myData).
    DO n TIMES.
      ch = myData(sy-index).
    ENDDO.
    While this code would work, the problem is that I am actually iterating over myData two times. STRLEN itself is internally iterating over myData to compute the length.
    Is there a more efficient looping mechanism without going through STRLEN?
    Thank you in advance for your help.
    Pradeep

    Hi,
    You can try this when it comes to converting things
        WHILE myData IS NOT INITIAL.
    do something
        ENDIF.
        myData = myData+1(*).
    Eddy
    PS.
    Put yourself on the SDN world map (http://sdn.idizaai.be/sdn_world/sdn_world.html) and earn 25 points.
    Spread the wor(l)d!

  • Looping over Nested Structure

    Hey Guys,
    I have a component that returns a structure. The structure is
    called ContactQuery. ContactQuery has to elements, one called
    Results, and one called Success. Results contains the data I want
    to loop over. If you try looping over the ContactQuery by using
    CFLoop and specify the ContactQuery as the collection, of course it
    only loops twice (once for Results, once for Success). How can I
    loop over the Results structure withing ContactQuery? You can see
    the dump of the structure at:
    http://www.digitalswordsmen.com/cfschedule/admin/Create_Tokens_Table.cfm
    Attached is the code I have. I am just unsure of the syntax
    for looping over the Results section of the structure.
    Thank you.

    Nope. I am dumb and didn't really think about it. The fact
    that it is a query nested in a structure threw me off. The code
    that works was
    <cfloop query="ContactQuery.Results">
    <tr>
    <td></td><td>#firstname#</td><td>#lastname#</td><td>#email#</td><td>#randrange(10000,9999 9)#</td>
    </tr>
    </cfloop>
    Thanks for the help, sorry about that dumb question.

  • Looping over query by month

    etings,
    I have a query I am pulling that has a date field entitled, "Completed". I am attempting to loop over the query by date to slice and dice the data for a table and chart. Here is what I have done thus far...
    Setup two variables where I am only interested in the month. My plan is to fileter the date by month so I can pull the data out by month.
        <cfset startDate = #DatePart('m','01/01/09')#>
        <cfset endDate = #DatePart('m',Now())#>
    Here is my loop...
        <cfloop from = "#startDate#" to = "#endDate#" index = "i" step = "1">
    Here is one of my QoQs within the loop...
            <cfquery name="NPS0" dbtype="query">
            SELECT *
            FROM rsNPS
            WHERE #DatePart('m',rsNPS.completed)# = #i#
            </cfquery>
    I am having difficulties in getting this to work. Has anyone ever done something like this. I feel like the answer is right in front of me, but I have been staring at this code for a while. If anyone has any thoughts, I would be glad to hear them.
    ~Clay

    fs22 wrote:
             <cfquery name="NPS0" dbtype="query">
            SELECT *
            FROM rsNPS
            WHERE #DatePart('m',rsNPS.completed)# = #i#
            </cfquery>
    QoQ are a separate beast. You cannot use standard CF functions inside them.  AFAIK, QoQ only support a few functions like CAST, UPPER, LOWER, etcetera.  So as Dan suggested, you should peform the date functions in your database query.

  • Loop over form values & insert into db

    Form
    prod_id     prod_name       prod_price    prod_status
    001         product 001     1.00          1            
    002         product 002     2.00          1      
    003         product 003     3.00          0      
    004         product 004     4.00          0      
    Form Dump
    prod_name      product 001,product 002,product 003,product 004
    FIELDNAMES     prod_id, prod_name, prod_price, prod_status
    prod_price     1.00,2.00,3.00,4.00
    prod_status    1,1,0,0
    prod_id        001,002,003
    I want to update a few fields, prod_price and prod_status. I submit these values to my update page but I'm not sure how to loop over these values and update by the prod_id. In my update page I'm using cfdump and I see the structure of the form, the fieldnames as well as the prod_id, prod_name, etc and their values.
    My question is how do I loop over these form values so I'll be able to update by each prod_id? I've played around with looping over the form collection values but no luck.

    When I do stuff like this, I append the "id" value to the end of each form field.  That enables me to ensure the other fields match up.
    When processing the form, I generally do something like this:
    <cfloop list="#form.fieldnames# index="ThisField">
    <cfif left(ThisField, 9) is "prod_name">
    <cfscript>
    ThisID = removechars(thisfield, 9);
    ThisName = form["prod_name" & ThisID];
    same for other fields
    Then do something with those variables.

  • Error when looping over list

    Looping over a series of lists created from form fields
    generates an error when one of the fields on the form has been left
    blank. The form is a list of event dates, start times and end
    times. One event can have a number of times.
    When the end time is uncertain, we want to leave it blank.
    However, doing so shortens the list created from #form.endtime# so
    that the lists don't match and there's an error message:
    "Invalid list index 2.
    In function ListGetAt(list, index [, delimiters]), the value
    of index, 2, is not a valid as the first argument (this list has 1
    elements). Valid indexes are in the range 1 through the number of
    elements in the list."
    How do you get around this problem? Tx.

    yoman,
    No need for separate forms. Use a counter to number each
    group of field names
    <input name="EventDateID1" ...>
    <input name="EventDate1" ...>
    <input name="EventDateID2" ...>
    <input name="EventDate2" ...>
    Then loop through the form fields on your action page
    <cfloop from="1" to="#form.maxCounter#"
    index="counter">
    <cfset EventDateID = form["EventDateID#counter#">
    <cfset EventDate = form["EventDate#counter#">
    ... rest of fields
    <cfquery name="UpdateFeatures" datasource="#dsn#">
    UPDATE EventDates
    SET EventDate = '#EventDate#', ....
    WHERE EventDateID = #EventDateID#
    </cfquery>
    </cfloop>
    You should validate the values and/or use cfqueryparam

Maybe you are looking for

  • Is there a way to stop a query just after the cursor/plan is produced by CBO?

    Following suggestions of Kerry Osborne&#8217;s Oracle Blog &raquo; Blog Archive &raquo; Explain Plan Lies &#8211; Kerry Osborn- on the lies of "Explain plan" (and of "set autotrace on"  too) I'd like to try to stop a query/DML before actually it star

  • Has anyone seen the crawling ANTS application

    A friend of mine told me about an application where ants crawl on your screen. I found it on you tube, but have no idea how to get it. Has anyone heard of this, and if so how do I get it. Thanks!

  • TS1292 What if I don't have a iTunes gift card?

    Dear apple support communities, I am having trouble finding the codes for iTunes gift cards and iTunes gift using my iPad device to complete my new apple I'd account, is there any way I can complete my account without using an iTunes gift card codes?

  • Problem to boot up installation DVD from another optical drive.

    Hello, i am trying to install the Snow Leopard OS to my MBA (10.5.2) using the optical drive of my iMac (Lion). The moment i power up the MBA (with the option button being pressed) after i log into the wi-fi network, the only boot device i see is the

  • NI FBUS - HSE/H1 Capabilities

    I am in the process of looking for alternatives to Rockwell 1757-FFLD (foundation fieldbus linking device).  We have a couple of major issues with this device that are requiring us to look for a different solution.   1.  Can we use the NI FBUS - HSE/