ForEach Loop Iteration Order

Hi,
I have a SSIS package that uses a Foreach Loop Container to iterate through a series of flat files. The order in which the files are iterated through is based on the name of the file. Is it possible to change the iteration order? More specifically, can the
iteration order be changed to the date when the file was placed in the iteration folder? i.e files that have been sitting in a folder for a longer amount of time get processed first?

you can change order but for that you need to use a control table based approach. Using file enumerator  will always take order based on filename.
The approach would be like this. Have a for each loop based on file enumerator first. Take the filename and arrival date (this you can get inside a script task see
http://jamelcato.com/111/how-to-check-last-modified-date-using-ssis/) and populate the table with the information.
Have a object variable and set query as 
SELECT fileName
FROM table
ORDER BY DateField
Then have a for each loop to iterate through object variable use ADO enumerator
http://www.select-sql.com/mssql/loop-through-ado-recordset-in-ssis.html
This would make sure it iterates based on file date value. Then have a variable inside to retrieve filename each time and use it for whatever processing you want.
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • Foreach loop iteration question

    Here's what I want to do. I have a list of items that I need to insert a comma between. For the last item there should be no comma afterward, so I need to flag this loop iteration as special.
    <c:set var="numRsns" value="${fn.length(networksForm.regionalSportsNetworkStations)}"/>
    <c:forEach var="rsn" items="${networksForm.regionalSportsNetworkStations}" varStatus="rsncounter">
         <c:if test="??? < numRsns" >
                               <b><c:out value="${rsn.description}" escapeXml="false" /></b>
                     </c:if>
         <b><c:out value="${rsn.description}," escapeXml="false" /></b>
    </c:forEach>How can I find out what the current iteration of the loop is? I am fairly new to JSP and JSTL so all help is appreciated.
    Thanks!

    Another useful feature of the loop status variable - it has boolean properties "first" and "last" to indicate if it is the first or last row
    <b>
    <c:forEach var="rsn" items="${networksForm.regionalSportsNetworkStations}" varStatus="rsncounter">
      <c:out value="${rsn.description}" escapeXml="false" />
      <c:if test="${rsncounter.last}>,</c:if>
    </c:forEach>
    </b>{code}
    Also because everything in your loop is bolded, why not just put bold tags around the whole thing, rather than mark up each individual element?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Yet another Try Catch question. Iterating through a ForEach loop

    Confused on error handling in a Powershell ForEach loop. I’m looping through a list of registry keys, attempting
     to open each one. If it succeeds, I do a bunch of stuff. If it fails, I want to skip to the next iteration.
    If I was doing It in VBScript I’d do this:
    For Each Thing In colThings
    Open Thing
    If Err.Number <> 0 Then
    “oops”
    Else
    Do stuff
    Do stuff
    Do stuff
    End If
    Next
    This is what I came up with in PowerShell. It seems to work, but just doesn’t seem powershell-ish. There must be a better way to use the catch output than just creating a $return variable and assigning it success or fail?
    ForEach ($subKeyName in $subKeyNames)
    try{$subKey = $baseKey.OpenSubKey("$subKeyName")}
    catch{$return = "error" }
    If($return -eq "error" )
    “Oops”
    Else
    Do stuff
    Do stuff
    Do Stuff

     
    I totally get what you're saying about formatting. I don't' have any habits yet, since I've only been working in Powershell since... well, what time is it now?
    Unfortunately, It Has Been Decreed that we are no longer to use VBScript for any engineering solutions at work, so my 15 years experience in it now needs to be transitioned over asap. I don't have the luxury of crawling before I run. I'm trying not to be
    frustrated, but it's like an English major waking up one day and being told "You must now speak French exclusively. Here's a book."
    The Do Stuff example of my ForEach loop is about 50 lines of code involving matching values in subkeys of this registry key with another and collecting output. I tried wrapping the whole thing in a try section based on some examples, but it seemed odd, that's
    why I'm asking. I'm used to tightly focused error handling at the point where an error may occur.
    In this example I'm only interested in whether or not I can open the subkey (it exists, but I may not have permission). If I can't, there's no point in continuing with this iteration of the loop, I want to skip to the next one. So why include all the "Do
    Stuff" in the the try section? From a readability viewpoint, it doesn't seem helpful.
    Also, there may be more error handling deeper in the code. If I then put that in a try/catch, and then something else inside that, now I have nested try/catches mixed in with nested if/elses, all wrapped in a For loop.
    Again, I can see how it works logically, but for readability not so much, and having all these braces 50 lines apart to match up is giving me eye strain :).
    It sounds like David is agreeing with jrv, that putting the entire ForEach loop code into a try/catch is the conventional way to do it. I guess it makes as much sense as putting it all in an If-else-Endif, and I just need to adjust my paradigm.
    But if not, my specific question was more along the lines of, is there a built in way to tell that the catch section has been executed, rather than me using it to populate an arbitrary variable and then read it? In VBScript, you execute something, and the
    next line, you check the Err.number. I wasn't sure if you could do that with a try/catch.

  • Is it possible to control which iteration a ForEach loop should execute?

    I'm using the example "SequenceFilePostStepFailure" so that the user can decide what to do when a step failes. If you choose "retry", the program returns and reruns a VI inside a ForEach loop. The problem is that the ForEach loop loads the VI with the next set of parameters.
    Is there a way to control this? I would like the ForEach loop to not increment when the user wants to retry the step. It seems to me that the whole loop is considered 1 step, and that it is incremented because the whole loop is re run.
    I was told that this is not the case if it's an error instead of a failure, and the user presses "retry".
    Thanks

    Never mind, i figuered it out. "RunState.Caller" were setting values in the wrong sequence.

  • Foreach Loop only looping once

    Hi,
    Please be patient and bear with me, for I am new to SSIS packages.
    I am using SQL Server 2008 R2 to host the SQL Agent job and the SSIS package.
    I am using Visual Studio 2008 Professional Edition for designing the SSIS package. It is version 9.0.30729, Version 3.5 SP1.
    I am on a Windows 8 machine.
    My Foreach Loop Container seems to iterate only once when it should iterate numerous times, and this issue happens BOTH when I execute the SSIS package from within Visual Studio AND when I run a SQL Agent job to execute the SSIS package.
    For the solution within Visual Studio, I have False for the property Run64BitRuntime.
    In the SSIS pckg in Visual Studio, I have in the Variables pane a number of variables and these following variables pertain to my problem:
    Name: objRs      Scope: the name of the SSIS package     DataType: Object    Value: System.Object
    Name: txtVendorFamilyNumber   Scope: the name of the SSIS package  DataType: String   Value: 111111
    The value "111111" that I entered into the txtVendorFamilyNumber variable in the Variable Pane is NOT a realistic value as there are no vendor family numbers that have the value 111111. I will populate dynamically the real vendor family numbers
    from within the SSIS package.
    When I imported the SSIS package to SQL Server 2008 R2, via the ellipsis button for the Protection Level I chose the "Rely on server storage and roles for access control" choice.
    Concerning the flow of the SSIS package, going down within Visual Studio from the beginning of the flow of the SSIS package, eventually I have an Execute SQL Task. In its General tab, it has "1252" for CodePage property, "Full result set"
    for ResultSet property, "OLE DB" for ConnectionType property, "Direct input" for SQL Source Type property, "False" for BypassPrepare property, and the following for the SQLStatement property:
         select txtVendorFamilyNumber from tmpVendorFamily  where VendorID = (select min(VendorID) from tmpVendorFamily)
    In the tmpVendorFamily table on SQL Server 2008 R2, there are 379 rows of results for the SELECT statement above (starting with the values 100110, 100115, 100120, 100130, through the LAST row's value 106370.
    In the Parameter Mapping tab of the Execute SQL Task Editor, I have nothing. In the Expressions tab of the Execute SQL Task Editor, I have nothing.
    In the Result Set tab of the Execute SQL Task Editor, I have the value 0 for Result Name property and I have the value User::objRs as the value in the Variable Name property.
    This Execute SQL Task has a green arrow (Constraint evaluation operation, Success in Value drop down) to the Foreach Loop Container.
    In the Foreach Loop Editor, in the Collection tab, I have "Foreach ADO Enumerator" as the value in the Enumerator property. In the drop down for ADO Object Source Variable, I have chosen the User::objRs, and I have the radio button "Rows in
    the first table" selected.
    In the Foreach Loop Editor, in the Expressions tab, I have nothing.
    In the Foreach Loop Editor, in the Variable Mappings tab, I have "User::txtVendorFamilyNumber" for the Variable property and I have the value "0" for the Index property.
    So in the Foreach Loop, I first have a Script Task with the ReadOnly variable User::txtVendorFamilyNumber and with the ReadWrite variable User::TESTING_OnlyTesting that I created with a package scope, string datatype, and no default value. This Script Task
    has the following code for testing purposes:
    Dim strFullVerbiage As String
    strFullVerbiage = "The value is: "
    Dts.Variables("User::TESTING_OnlyTesting").Value = strFullVerbiage + Dts.Variables("User::txtVendorFamilyNumber").Value.ToString()
    Dts.TaskResult = ScriptResults.Success
    I have next in the Foreach Loop Container a Send Mail task. In the Expressions tab of the Send Mail Task Editor, I have for the Message Source property the following:
          @[User::TESTING_OnlyTesting]
    The remaining tasks (including FTP Tasks) in the Foreach Loop Container are disabled for now as I am trying to figure out why the Foreach Loop only iterates the FIRST time, only iterates once.
    When I run on SQL Server 2008 R2 the SELECT statement from the Execute SQL Task, I get 379 rows of results. The default value 111111 that I entered into the Variable Pane for the txtVendorFamilyNumber variable does NOT exist in any of these 379 rows of results.
    The 1st row of results has for the txtVendorFamilyNumber column the value 100110. Then the subsequent rows of results have the values 100115, 100120, 100130, et cetera, ending with the value 106370 in the last row of results.
    I imported the SSIS package into Integration Services on SQL Server 2008 R2. When I imported to Integration Services, in the Import Package editor for the Protection Level I chose the "Rely on server storage and roles for access control" choice
    because there are FTP Tasks and we needed to use this "Rely on server storage and roles for access control" choice.
    I created a SQL Agent job that executes this SSIS package.
    When I run the SQL Agent job, no error happens and I get only ONE email with the value 100110 for the vendor family number in it. I should get 379 emails total, the 2nd email showing 100115, the 3rd email showing 100120, et cetera.
    When I was testing while executing the SSIS package from within Visual Studio, I did NOT have the Send Mail task and I only had enabled one Script Task that had the ReadOnly variable User::txtVendorFamilyNumber and the following lines of code:
    MsgBox(CType(Dts.Variables("User::txtVendorFamilyNumber").Value, String))
    Dts.TaskResult = ScriptResults.Success
    Executing the SSIS package with only this Script Task enabled within the Foreach Loop Container, I would get the ONE message box showing 100110 but I would not get any message box for a SECOND ITERATION of the loop.
    Since my txtVendorFamilyNumber in the Variables Pane has the default hard-coded value 111111 that does NOT exist in the result set of the Execute SQL Task that feeds the Foreach Loop, and since the first and only email sent shows the value 100110 when I
    run the SQL Agent job that runs the SSIS package that is set up to send an email from within the Foreach Loop Container, the FIRST LOOP seems to run correctly and shows correctly the 1st value 100110 in the 379 rows of results that populate the Foreach Loop
    Container. Why does the Foreach Loop Container NOT loop more than once?
    Could anybody give me any suggestions as to what the problem might be?
    I thank you in advance for your consideration of my problem. I have been reading and reading on the Internet to try to find a solution but I have not solved yet my problem with the Foreach loop only iterating once.
    Thanks much to you.

    Gregarious greetings Arthur,
    I very much appreciate your reply.
    This morning I figured out my problem with the help of a fellow employee.
    In my original post higher up, I had typed about the SELECT statement in the Execute SQL Task that is just before the Foreach Loop Container and that populates the User::objRs, and this SELECT statement was in the old DTS package in an old ActiveX script
    task. The SELECT statement was in an old DTS package in an old ActiveX script task and I am creating a new SSIS package to replace the old DTS package so that we can move from the old version of SQL Server to a new SQL Server 2008 R2 server. Here is that
    SELECT statement:
     select txtVendorFamilyNumber from tmpVendorFamily  where VendorID = (select min(VendorID) from tmpVendorFamily)
    That SELECT statement above returns ONLY ONE result. I had not noticed it. That SELECT statement fills the objRs result set. The green arrow goes from the Execute SQL Task that has the SELECT statement down to the Foreach Loop Container that loops over the
    result set. Since the SELECT statement that fills the result set only has one row of results, the Foreach Loop only looped once.
    So for the Execute SQL Task that populates the result set User::objRs, I changed the SELECT statement to be the following:
    --In the Utilities DB, this tmpVendorFamily table
    --has only two columns named VendorID and txtVendorFamilyNumber.  
    SELECT DISTINCT txtVendorFamilyNumber
    FROM Utilities.dbo.tmpVendorFamily
    ORDER BY txtVendorFamilyNumber
    Now the Foreach Loop will loop 379 times since the SELECT statement immediately above yields 379 rows of results.
    So the Foreach Loop Container was fine. Its Collection tab has the "Foreach ADO Enumerator" for the Enumerator and has the "User::objRs" for the ADO Object Source Variable. Its Variable Mappings tab has "User::txtVendorFamilyNumber"
    for the Variable and has "0" for the Index.
    My problem was the SELECT statement in the Execute SQL Task that immediately precedes the Foreach Loop Container and that fills the User::objRs result set. The SELECT statement yielded only ONE row of results. When I corrected this morning that SELECT statement
    so that it correctly yields 379 rows of results, the Foreach Loop Container loops 379 rows.
    Thanks again for replying and trying to help. I very much appreciate it.
    I consider this thread that I created to be closed since I figured out this morning how I needed to correct the SELECT statement in the Execute SQL Task that fills the result set on which the Foreach Loop loops.
    Misko_Hviezdoslav   27-JAN-2015

  • [Forum FAQ] How to calculate the total count of insert rows within a Foreach Loop Container in SSIS?

    Introduction
    We need to loop through all the flat files that have the same structure in a folder and import all the data to a single SQL Server table. How can we obtain the total count of the rows inserted to the destination SQL Server table?
    Solution
    We can use Execute SQL Task or Script Task to aggregate the row count increment for each iteration of the Foreach Loop Container. The following steps are the preparations before we add the Execute SQL Task or Script Task:
    Create a String type variable FilePath, two Int32 type variables InsertRowCnt and TotalRowCnt.
    Drag a Foreach Loop Container to the Control Flow design surface, set the Enumerator to “Foreach File Enumerator”, specify the source folder and the files extension, and set the “Retrieve file name” option to “Fully qualified”.
    On the “Variable Mappings” tab of the container, map the variable FilePath to the collection value.
    Drag a Data Flow Task to the container, in the Data Flow Task, add a Flat File Source, a Row Count Transformation, and an OLE DB Destination, and join them. Create a Flat File Connection Manager to connect to one of the flat files, and then configure the
    Flat File Source as well as the OLE DB Destination adapter. Set the variable for the Row Count Transformation to “User::InsertRowCnt”.
    Open the Property Expressions Editor for the Flat File Connection Manager, and set the expression of “ConnectionString” property to
    “@[User::FilePath]”.
    (I) Execute SQL Task Method:
    In the Control Flow, drag an Execute SQL Task under the Data Flow Task and join them.
    Create one or using any one existing OLE DB Connection Manager for the Execute SQL Task, set the “ResultSet” option to “Single row”, and then set the “SQLStatement” property to:
    DECLARE @InsertRowCnt INT,
                   @TotalRowCnt INT
    SET @InsertRowCnt=?
    SET @TotalRowCnt=?
    SET @TotalRowCnt=@InsertRowCnt+@TotalRowCnt
    SELECT TotalRowCnt=@TotalRowCnt
    On to parameter 1. 
    On the “Result Set” tab of the Execute SQL Task, map result 0 to variable “User::TotalRowCnt”.
    (II) Script Task Method:
    In the Control Flow, drag a Script Task under the Data Flow Task and join them.
    In the Script Task, select variable InsertRowCnt for “ReadOnlyVariables” option, and select variable TotalRowCnt for “ReadWriteVariables”.
    Edit the Main method as follows (C#):
    public void Main()
    // TODO: Add your code here
    int InsertRowCnt = Convert.ToInt32(Dts.Variables["User::InsertRowCnt"].Value.ToString()
    int TotalRowCnt = Convert.ToInt32(Dts.Variables["User::TotalRowCnt"].Value.ToString());
    TotalRowCnt = TotalRowCnt + InsertRowCnt;
    Dts.Variables["User::InsertRowCnt"].Value = TotalRowCnt;
    Dts.TaskResult = (int)ScriptResults.Success;
              Or (VB)
              Public Sub Main()
            ' Add your code here
            Dim InsertRowCnt As Integer =        
            Convert.ToInt32(Dts.Variables("User::InsertRowCnt").Value.ToString())
            Dim TotalRowCnt As Integer =
            Convert.ToInt32(Dts.Variables("User::TotalRowCnt").Value.ToString())
            TotalRowCnt = TotalRowCnt + InsertRowCnt
            Dts.Variables("User::TotalRowCnt").Value = TotalRowCnt
            Dts.TaskResult = ScriptResults.Success
           End Sub
    Applies to
    Microsoft SQL Server 2005
    Microsoft SQL Server 2008
    Microsoft SQL Server 2008 R2
    Microsoft SQL Server 2012
    Microsoft SQL Server 2014
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    Hi ITBobbyP,
    If I understand correctly, you want to load data from multiple sheets in an .xlsx file into a SQL Server table.
    If in this scenario, please refer to the following tips:
    The Foreach Loop container should be configured as shown below:
    Enumerator: Foreach ADO.NET Schema Rowset Enumerator
    Connection String: The OLE DB Connection String for the excel file.
    Schema: Tables.
    In the Variable Mapping, map the variable to Sheet_Name, and change the Index from 0 to 2.
    The connection string for Excel Connection Manager is the original one, we needn’t make any change.
    Change Table Name or View name to the variable Sheet_Name.
    If you want to load data from multiple sheets in multiple .xlsx files into a SQL Server table, please refer to following thread:
    http://stackoverflow.com/questions/7411741/how-to-loop-through-excel-files-and-load-them-into-a-database-using-ssis-package
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Foreach loop in static block won't compile

    When I try to compile this:public class TestEnum
      private static String[] numerals =
          {"einz", "zwei", "drei", "vier"};
      static
        for (String n : numerals)
          // doesn't matter what's in here
      public static void main(String[] args)
    }I get this exception:An exception has occurred in the compiler (1.4.2-beta).
    java.lang.NullPointerException
        at com.sun.tools.javac.comp.Lower.visitArrayForeachLoop(Lower.java:2269)
        at com.sun.tools.javac.comp.Lower.visitForeachLoop(Lower.java:2242)
        at com.sun.tools.javac.tree.Tree$ForeachLoop.accept(Tree.java:559)
        at com.sun.tools.javac.comp.Lower.translate(Lower.java:1580)
        at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:51)
        at com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:131)
        at com.sun.tools.javac.tree.Tree$Block.accept(Tree.java:497)
        at com.sun.tools.javac.comp.Lower.translate(Lower.java:1580)
        at com.sun.tools.javac.comp.Lower.visitClassDef(Lower.java:1645)
        at com.sun.tools.javac.tree.Tree$ClassDef.accept(Tree.java:409)
        at com.sun.tools.javac.comp.Lower.translate(Lower.java:1580)
        at com.sun.tools.javac.comp.Lower.translate(Lower.java:1594)
        at com.sun.tools.javac.comp.Lower.translateTopLevelClass(Lower.java:2438)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:408)
        at com.sun.tools.javac.main.Main.compile(Main.java:523)
        at com.sun.tools.javac.Main.compile(Main.java:41)
        at com.sun.tools.javac.Main.main(Main.java:32)The same thing happens if I use foreach with a Collection instead an array. If I use an old-style for loop or Iterator in the static block, it compiles fine. I can also put the foreach loop in the main method, and it works. Is this a known bug?

    You guys rock. Thanks for finding this problem. I'll get it fixed.

  • Using an ssis variable object as a data source in a foreach loop container

    hi we run 2012 std.  I have an ssis var of type object that is hydrated from a dynamic query in an execute sql task.  I can count on one thing in this object and that is that ID will always be the first "col" on each "row". 
    Otherwise, resultset can contain a variety of things based on params passed to this sub pkg.
    I'd like to introduce a for each loop on this object and tap into index 0, ie the id column.  
    The first question is "will I be able to parse this object's id in a for each component?".
    In the for each loop container properties, I c an item enumerator, ado enumerator, ado.net schema rowset and variable enumerator as enumerator choices.  Which do I want if the answer to the 1st question is yes?

    hoping 2 avoid a data flow.  I wonder if what u r saying is that I cannot use an felc to do this.  Or if u r showing one of many alternatives.
    Sorry, bad title.  I just changed that.
    I just tried foreach from variable enumerator and aborted with a message that said my variable "coll" doesn't have an enumerator.  Going 2 try some of the other choices.
    I just tried ado enumerator and from what I can c it isn't actually iterating thru my resultset even once. 
    I just tried a foreach item enumerator giving "column 0" a data type that matches my ID but from what I can tell the component isn't iterating thru my collection. 
    ado.net schema rowset doesn't look inviting at all in that it looks like it wants to go back to the db.  Not what I had in mind having already gotten this resultset into memory.
    according to this article u r supposed to be able to do this using ado enumerator
    social.technet.microsoft.com slash wiki slash articles slash sis-looping-over-object-variables-with-as-ado-enumeration-in-foreach-loop-container.aspx

  • Nested af:forEach loop

    Hi,
    How can i use nested af:forEach loop. I can't use af:iterator for sure, please provide solution only using af:forEach.
    <af:forEach items ="#{bindings.parentVO.rangeSet}" var ="parent">
    <af:forEach items ="#{parent.chidVO}" var="child">
    <af:outputLabel value="#{child.empId}"/>
    </af:forEach>
    </af:forEach>
    here child.empId is not printing any value. Data is proper and bindings are also fine. Please guide why forEach is not working with parent-child VO?
    I guess in second forEach loop I am missing something like parent.childVO._something_ i tried using parent.childVO.rangeSet and other option but it didn't work
    Edited by: 899404 on Mar 14, 2012 10:47 AM

    you could use af:iterator for your use-case.
    Please find sample based on your use-case:
    NestedIteratorSample.jspx:
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <af:document title="Sample" id="d1">
    <af:messages id="m1"/>
    <af:form id="f1">
    <af:panelGroupLayout id="pgl1" layout="vertical">
    <af:iterator rows="#{bindings.Departments.rangeSize}" var="row"
    value="#{bindings.Departments.treeModel}" id="outerIt">
    <af:outputText value="Employees in #{row.DepartmentName}" id="ot1"/>
    <af:iterator rows="#{bindings.EmployeesVO.rangeSize}" var="detailRow" value="#{row.EmployeesVO}"
    id="innerIt">
    <af:outputText value="#{'----------------'} #{detailRow.FirstName} #{detailRow.LastName}" id="ot2"/>
    </af:iterator>
    </af:iterator>
    </af:panelGroupLayout>
    </af:form>
    </af:document>
    </f:view>
    </jsp:root>
    NestedIteratorSamplePageDef.xml:
    <?xml version="1.0" encoding="UTF-8" ?>
    <pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel" version="11.1.2.60.17" id="NestedIteratorSamplePageDef"
    Package="com.samples.subbanasolutions.view.pageDefs">
    <parameters/>
    <executables>
    <iterator Binds="Departments" RangeSize="25" DataControl="AppModuleDataControl" id="DepartmentsIterator"/>
    </executables>
    <bindings>
    <tree IterBinding="DepartmentsIterator" id="Departments">
    <nodeDefinition DefName="com.samples.subbanasolutions.model.DepartmentsVO" Name="Departments0">
    <AttrNames>
    <Item Value="DepartmentId"/>
    <Item Value="DepartmentName"/>
    </AttrNames>
    <Accessors>
    <Item Value="EmployeesVO"/>
    </Accessors>
    </nodeDefinition>
    <nodeDefinition DefName="com.samples.subbanasolutions.model.EmployeesVO" Name="Departments1">
    <AttrNames>
    <Item Value="EmployeeId"/>
    <Item Value="FirstName"/>
    <Item Value="LastName"/>
    </AttrNames>
    </nodeDefinition>
    </tree>
    </bindings>
    </pageDefinition>

  • Simulate Signal Express VI is sending two periods of the wave per loop iteration - how can I reduce this to one period?

    Hello,
    I've been trying to use the Signal Generator Express VI and DAQ Assistant in order to generate an output waveform, as seen in this NI tutorial video:
    http://www.ni.com/academic/students/learn-daq/generate/ (timestamp is at 2:07 for what I'm trying to do)
    For background, I'm trying to move a piston device using Labview. The sine waveform is intended to move the piston at a smooth speed. For every loop iteration, the Simulate Signal VI running into my DAQ Assistant moves the piston to its maximum displacement and back twice. I cannot determine why this is occuring.
    The settings in my "Configure Simulate Signal" tab are as follows:
    Frequency: 1Hz
    Phase: 90 deg
    Amplitude: 2
    Offset: -2
    I would like my piston to only reach its maximum displacement and return for every iteration of the loop. I've tried adjusting all of the settings within "Configure Simluate Signal" but I can only work in even numbers - sending the piston back and fourth two, four, or eight times, ect.

    The Simulate Signal VI is set for integer number of cycles and the default frequency set in the Cycles per Second control is 3.75 Hz. That results in the signal containing three complete cycles and the data array contains 8000 elements, not the nominla 10000 specified in the Express VI dialog.
    If you only want one cycle, you need to specify the signal so that you only get one. Either reduce the frequency or reduce the number of samples.
    As you have noticed Express VIs do one thing exceedingly well: They obscure what is going on inside.  I pulled your signal generation code out into a separate VI and then created a generator which will generate the same signal but allow you to select the number of cycles. It uses the Sine Waveform.vi from the Signal Processing  >> Waveform Generation palette.
    I also recommend that you change the structure of your program. The use of sequence structures is discouraged in LabVIEW  because they defeat dataflow are very inflexible when changes need to be made. A Producer/Consumer Design Pattern plus a state machine would probably be a good choice. This will allow separation of the daq acquisition from the saving to file so that the timing of one does not constrain the timing of the other.
    Setting the Analog Input Read to read multiple samples simultaneously and using the hardware timing of the data acquisiton device will get data faster and the timing will be precisely (compared to software timing) controlled by the hardware.
    Writing to the same file in parallel loops probably results in some strange behavior such as differing numbers of writes from acquired data compared to generated cycles. As the file grows, the writes may slow down due to the OS needing to fragment or reallocate space for the file.
    Lynn
    Attachments:
    Signal generator.vi ‏49 KB

  • JSTL forEach: zero iteration is not allowed

    I have just written one of my first JSP pages with JSTL.
    I used
    <c:forEach var="numero" begin="0" end="${righe -1}" >
    to replace
    for (int i = 0; i < righe; i++ )
    It seems to me that a c:forEach loop must be executed at least one time: in fact setting begin = end
    the loop is executed once while setting end < begin causes an exception.
    So I had to put the c:forEach inside a <c:if test="${righe > 0}"> .... </c:if>
    Is there a better and cleaner way to translate a for loop into JSTL ?
    Thanks

    Nope, doesn't look like it.
    It states clearly in the documentation:
    end is INCLUSIVE
    end must be >= begin
    So your if tag around the forEach seems the only solution. I agree its not perfect, but it can be done.
    What is the code you are repeating? Most of the time you want to iterate this variable i, ACTUALLY what you are doing is iterating through an array. In that case use the forEach tag with the var and items attributes, and it works wonderfully.
    Cheers,
    evnafets

  • ConcurrentModificationException while attempting a foreach loop

    I'm writing a bit of code using JGraphT (not necessarily important that you understand how to use it though), and I'm running into a ConcurrentModificationException.
    public static ArrayList<DirectedGraph<Long, DefaultEdge>> level2()
              Set<Long> vertices = graph.vertexSet();
              ArrayList<DirectedGraph<Long, DefaultEdge>> graphs = new ArrayList<DirectedGraph<Long, DefaultEdge>>();
              ArrayList<GraphSizeStorage> storage = new ArrayList<GraphSizeStorage>();
              int counter = 0;
              double foo = vertices.size()/10;
              System.out.print("\nCalculating the Level 2 graphs for all nodes: ");
              for(Long v : vertices)
                   if(counter % foo == 0 && counter >= foo) { System.out.print("."); }
                   DirectedGraph<Long, DefaultEdge> g = new DefaultDirectedGraph<Long, DefaultEdge>(DefaultEdge.class);
                   g.addVertex(v);
                   System.out.println("Adding Vertex: " + v);
                   Set<DefaultEdge> edges = graph.outgoingEdgesOf(v);
                   for(DefaultEdge e : edges)
                        g.addVertex(graph.getEdgeTarget(e));
                        System.out.println("Adding Vertex: " + graph.getEdgeTarget(e));
                        g.addEdge(v, graph.getEdgeTarget(e));
                        System.out.println("Adding Edge from " + v + " to " + graph.getEdgeTarget(e));
                   //At this point, level 1 should be complete.
                   //To get level 2, I'll get a set of g's vertices, and for all vertices that aren't v,
                   //I'll basically add a new edge, the same way I did above.
                   DirectedGraph<Long, DefaultEdge> gClone = g;
                   Set<Long> gVertices = gClone.vertexSet();
                   for(Long v2 : gVertices)
                   {At that foreach loop near the end, I get the exception. The two lines before it were recently modified (to no avail) in hopes of fixing it; instead of two lines, it used to be one line that said
    Set<Long> gVertices = g.vertexSet();
    My question is: Is there an easy way to get around this exception? Would it be possible to copy the variable g instead of making a reference to it? How about its vertexSet?
    Thanks for your help
    KFJ

    KungfuJoe wrote:
    Eh, forget about it. I modified the loops, they don't give me too much trouble anymore. Optimization is key I suppose.If "optimisation" mean don't modify the collection when iterating over it.

  • Nested foreach loops

    On a jsp page, I am trying to iterate though one list via c:foreach, and use the values from this iteration to loop through a second foreach loop. Is it possible to dynamically use the iterator object value to access another hashmap or hashtable?
    Like:
    <c:forEach items="${authors}" var="o">
      <c:out value="${o.name}"/>
    //  then get books by that author
      <c:forEach items="${authorBooks[${o.id}]" var="d">Where authors is a list of author objects with propertyies id, and name. And authorBooks is a Hashtable which has authorId as key values, the data is a list of books for that author.

    It is probably an issue with types.
    Is the type of the object you are looking up on, the same as the type that you created the hashmap with?
    This code might help with debugging:
    <c:out value="The type of o.id = ${o.id}"/></br>
    <c:forEach var="entry" items="${authorBooks}">
      <c:out value="Entry ${entry.key} = ${entry.value}.   Type of key is ${entry.key.class}"/><br>
    </c:forEach>

  • How can I load a .xlsx File into a SQL Server Table using a Foreach Loop Container in SSIS?

    I know I've REALLY struggled with this before. I just don't understand why this has to be soooooo difficult.
    I can very easily do a straight Data Pump of a .xlsX File into a SQL Server Table using a normal Excel Connection and a normal Excel Source...simply converting Unicode to DT_STR and then using an OLE DB Destination of the SQL Server Table.
    If I want to make the SSIS Package a little more flexible by allowing multiple .xlsX spreadsheets to be pumped in by using a Foreach Loop Container, the whole SSIS Package seems to go to hell in a hand basket. I simply do the following...
    Put the Data Flow Task within the Foreach Loop Container
    Add the Variable Mapping Variable User::FilePath that I defined as a Variable and a string within the FOreach Loop Container
    I change the Excel Connection and its Expression to be ExcelFilePath ==> @[User::FilePath]
    I then try and change the Excel Source and its Data Access Mode to Table Name or view name variable and provide the Variable Name User::FilePath
    And that's when I run into trouble...
    Exception from HRESULT: 0xC02020E8
    Error at Data Flow Task [Excel Source [56]]:SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occured. Error code: 0x80004005.
    Error at Data Flow Task [Excel Source [56]]: Opening a rowset for "...(the EXACT Path and .xlsx File Name)...". Check that the object exists in the database. (And I know it's there!!!)
    I don't understand by adding a Foreach Loop Container to try and make this as efficient as possible has caused such an error unless I'm overlooking something. I have even tried delaying my validations and that doesn't seem to help.
    I have looked hard in Google and even YouTube to try and find a solution for this but for the life of me I cannot seem to find anything on pumping a .xlsX file into SQL Server using a Foreach Loop Container.
    Can ANYONE please help me out here? I'm at the end of my rope trying to get this to work. I think the last time I was in this quandry, trying to pump a .xlsX File into a SQL Server Table using a Foreach Loop Container in SSIS, I actually wrote a C# Script
    to write the contents of the .xlsX File into a .csv File and then Actually used the .csv File to pump the data into a SQL Server Table.
    Thanks for your review and am hoping and praying for a reply and solution.

    Hi ITBobbyP,
    If I understand correctly, you want to load data from multiple sheets in an .xlsx file into a SQL Server table.
    If in this scenario, please refer to the following tips:
    The Foreach Loop container should be configured as shown below:
    Enumerator: Foreach ADO.NET Schema Rowset Enumerator
    Connection String: The OLE DB Connection String for the excel file.
    Schema: Tables.
    In the Variable Mapping, map the variable to Sheet_Name, and change the Index from 0 to 2.
    The connection string for Excel Connection Manager is the original one, we needn’t make any change.
    Change Table Name or View name to the variable Sheet_Name.
    If you want to load data from multiple sheets in multiple .xlsx files into a SQL Server table, please refer to following thread:
    http://stackoverflow.com/questions/7411741/how-to-loop-through-excel-files-and-load-them-into-a-database-using-ssis-package
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • SSIS BULK INSERT unsing UNC inside of ForEach Loop Container Failed could not be opened. Operating system error code 5(Access is denied.)

    Hi,
    I am trying to figure out how to fix my problem
    Error: Could not be opened. Operating system error code 5(Access is denied.)
    Process Description:
    Target Database Server Reside on different Server in the Network
    SSIS Package runs from a Remote Server
    SSIS Package use a ForEachLoop Container to loop into a directory to do Bulk Insert
    SSIS Package use variables to specified the share location of the files using UNC like this
    \\server\files
    Database Service accounts under the Database is runing it has full permission on the share drive were the files reside.
    In the Execution Results tab shows the prepare SQL statement for the BULK insert and I can run the same exact the bulk insert in SSMS without errors, from the Database Server and from the server were SSIS package is executed.
    I am on a dead end and I don’t want to re-write SSIS to use Data Flow Task because is not flexible to update when metadata of the table changed.
    Below post it has almost the same situation:
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/8de13e74-709a-43a5-8be2-034b764ca44f/problem-with-bulk-insert-task-in-foreach-loop?forum=sqlintegrationservices

    Insteresting how I fixed the issue, Adding the Application Name into the SQL OLAP Connection String Fixed the issue. I am not sure why SQL Server wasn't able to open the file remotely without this.

Maybe you are looking for

  • Execute Process Task showing all the SSIS Config variables in SQL Job History

    Hi, Am using an Execute Process task to execute my child package. And executing the Parent package from a SQL JOB. I am using the same config file for both Parent and Child packages. After the Job execution was Successful / Failure, in Job history it

  • Unable to access table in another account in Apex

    Hi, In the Apex report, I am querying a table in another schema account. I even granted select access to it. Yet Apex keeps on complaining that the table does not exist. Thanks. 1 error has occurred Query cannot be parsed within the Builder. If you b

  • How can I edit a pdf that opens in preview  w maverick

    With new PAGES app in Maverick, I need to make changes to a pdf document....can't seem to figure out how?  Thanks

  • Nikon D800E Raw format

    Hi! I have a new Nikon D800E; cannot open photographies with the Nikon Raw format (NEF) in Photoshop elements 10. Is an upgrade foreseen? Ercole

  • NFSv4: Server returns NFS4ERR_GRACE on open

    I've problems reading files from a NFSv4 exported ZFS dataset. Server: Solaris 10 x86 u5 (5/08) Clients: Solaris 10 x86 u5 (5/08) I created a new zfs dataset: server# zfs create mypool/export/test server# zfs set sharenfs=ro mypool/export/test server