Map c:forEach

Hello All,
I have to display the parent child relationship in a table in a jsp.
I can have 3 levels the first one is home which can contain children and these children may or may not have children.I'm planning to using LinkedHashMap
whose key will be the parent and value is a transfer object which contains all its parent information and the list of children(again hasmap whose value contains the child info and its children).
I'm trying to display this structure in a table using c:forEach but could not succeed.I need to display parent followed by all its children and its sub children. Any ideas or snippet of code would be helpful
Thanks
Edited by: Greeshma12 on Oct 17, 2007 1:22 PM

c:forEach requires an object that implements the Collections interface, which a Map does not. What I would do is wrap the Map into a Bean of somesort. Have accessors for the Map's keySet method like a getEveryone() method that you can use the c:forEach on.
<c:forEach var="person" items="family.everyone">
Then have an accessor method for the Map itself, so you can access the particular person and components from the map, such as through this EL statement: family.tree[person] to get the value part of the entry.

Similar Messages

  • ForEach Block not working in BPM

    Hi all,
    I've developed a BP with a split mapping and ForEach block similar to the "MultipleFlightBookingCoordination" BP.
    But whatever I place inside the ForEach block is not executed. Not even a simple container operation is executed.
    I get no exceptions, no errors in process engine monitoring, everything looks fine.
    The ForEach block is listed in the work item selection and in the graphical view it looks like the steps inside the block have been executed but that's definitely not the case.
    Why is that??
    Thanks in advance
    Karsten

    Correlations shouldn't be mandatory but correct usage is imp.
    If forEach is used in multicast scenario, a proper correlation is required.
    The correct use of forEach is when u have multiple receivers and u r receiving data from multiple send step. Then a Receiver Determination step collects the list of receivers (in a multiline container). Now the forEach block gets executed for each receiver from the list.
    Regards,
    Prateek

  • How to expedite OCR process?

    Hi,
    A. How to expedite the OCR process for :
    1. One 50 MB, it takes  45 minutes to 1 hour minutes
    2. Multiple files size of 13 GB. It takes 20 hours to complete. And it has increased to 50 GB
    B. What is the best PC specification for me to experdite the OCR process. We have to let the machine running for days in order to complete the job
    My machine specification:
    File Type
    File Size
    OCR performed for one file or batch of files
    Total folder size OCR performed
    Machine Type(please obtain from Wardah)
    Time taken to OCR
    Software used(please obtain from Wardah)
    PDF
    For 1 file approx. 50MB
    OCR can be perform in 2 ways:
    One by one- it needs to be monitor if the OCR is complete to continue with other file.
    OCR in batch-, no need to monitor and is not limited to how many files. Usually done per volume or batch of files with large size.
    Unlimited
    CPU: Intel® Core ™2 Duo.
    Memory: 2GB
    Hard disk free space: 49.65GB/162.93GB
    OS: Windows 7 Professional
    For 1 file (50MB) it’s takes 45 minutes to 1 hour to finish.
    Adobe Acrobat 9 Pro Extended Version 9.5.5

    Yes send step is wating for an transport ack. I have 1ToN mapping and foreach block.
    Time for deadline branch  is 5 min
    Deadline branch  is executing in different periods of time for each message.
    [Send step] PE     AENGINE     @5F@     @DF\QProcessed successfully@     @8Q\QStill awaiting acknowledgment           @     26.10.2005     18:41:29
    [deadline step] PE     AENGINE     @5F@     @DF\QProcessed successfully@     @5F@     26.10.2005     19:02:24
    [Send step] PE     AENGINE     @5F@     @DF\QProcessed successfully@     @8Q\QStill awaiting acknowledgment           @     26.10.2005     19:02:25
    [deadline step]PE     AENGINE     @5F@     @DF\QProcessed successfully@     @5F@     26.10.2005     19:09:24
    Message was edited by: Denis Ivanov

  • Problem with default value for Billing when creating Business Partner

    In Sales Area data - Billing screen we want to default a value for Price List Type when creating a Busines Partner.
    We implemented  BADI 'BUPA_FRG0030_UPDATE'  and followed suggestions from another thread :
    Defaulting Currency Value to 'USD' during BP Creation.
    But This only seems to work when you change an existing BP.
    If we use FUNCTION 'CRM_BUPA_FRG0030_SAVE' in the BADI this function is called again by the system when saving the BP and causes a dump.
    Also the UPDATE functions only seem to work when you change an existing BP and not when creating one.
    Any suggestions if we can use another BADI or other function modules/methods ?
    Or some sample coding for implementing BUPAFRG0030_SAVE'  the correct way ?
    Thanks for the help,
    Steve

    Brent,
    When I use the latest build 10.1.3.3.81, this gets generated:
    <managed-property>
    <property-name>defaultValues</property-name>
    <map-entries>
    <map-entry>
    <key>ManagerId</key>
    <value>#{'#{jhsTypeConverter.stringToNumber['100']}'}</value>
    </map-entry>
    </map-entries>
    </managed-property>
    Which is slightly better, but still failing because the single quotes get mixed up.
    This should be generated:
    <managed-property>
    <property-name>defaultValues</property-name>
    <map-entries>
    <map-entry>
    <key>ManagerId</key>
    <value>#{"#{jhsTypeConverter.stringToNumber['100']}"}</value>
    </map-entry>
    </map-entries>
    </managed-property>
    which can be achieved by changing the defaultValuesBean.vm template like this:
    <managed-property>
    <property-name>defaultValues</property-name>
    <map-entries>
    #foreach ($defaultValue in $group.defaultValues.keySet())
    <map-entry>
    <key>$defaultValue</key>
    #if ($group.defaultValues.get($defaultValue).startsWith("#{"))
    <value>#{"$group.defaultValues.get($defaultValue)"}</value>
    #else <value>$group.defaultValues.get($defaultValue)</value> #end
    </map-entry>
    #end
    </map-entries>
    </managed-property>
    Steven Davelaar,
    JHeadstart team.

  • Deploying mappings by changing Source/production system using OMB Scripting

    Hi Mark,
    I am now trying to deploy my mappings from DEVELOPMENT environment to PRODUCTION environment.
    Now my mappings are point to DEVELOPMENT Source System and DEVELOPMENT target system. When I deploy these mappings should point to PRODUCTION Source System and PRODUCTION target System.
    I could get some help from the forum for deploying the mappings point to PRODUCTION target system, but I couldnt find any help how to change the Source System Location. I have exported all my mappings (.xml files) in the C:\OWBDeploy directory.
    How do we register and unregister a location using OMB Scripting?
    How to write a batch deployment action without using deployment manager?
    Provide a example to deploy the mappings using OMB script
    for both source and target systems locations.
    I am using Oracle 9.2, OWB 9.2.0.2.8, OWF 2.6 and OMB 9.2.0.2.8.
    Regards,
    Shreedhar

    Below script will deploy all the mappings in a module. It can be used with filter condition like mappings which start with ‘M_D’ or ‘M_F’ also. Above script will deploy mappings very effectively comparing with GUI. Frequent problem in OWB mapping execution ‘ TASK not found’ error will not occur, if we deploy the mappings using above scripts.
    Steps to Deploy All Mappings in a Module
    Start the OMB PLUS from Command Prompt or Start Menu
    Change the context to the respective Project
    Connect to Design Repository
    Register the Location Properties if the deployment is happening first time in the target schema.
    Change the context to the respective Module
    Use foreach and OWBCREATE command to create a Deployment Plan for Droping if any previous deployment for all mappings
    Use foreach and OWBCREATE command to create a Deployment Plan for Newly Deploying the Mapping
    Use foreach and OWBDEPLOY command to run the Drop Deployment Plan
    Commit
    Use for each and OWBDEPLOY command to run the Create Deployment Plan
    Example
    OMBCONNECT mis_owb904_rep/[email protected]:1521:ulyut03s
    OMBCC '/IGMS_MIS_GEMNCAP_FOC'
    OMBCONNECT RUNTIME 'ST_DWH_RUNTIME_FOC' USE PASSWORD ‘MIS_RT_OWNER’
    OMBREGISTER LOCATION 'ST_LOC_CURRENTMISTARGET_FOC' SET PROPERTIES (Host, Port, Service, Schema, Password) \
    VALUES ('10.202.148.176', 1521, 'ULYUT01M','MIS_OWNER', 'MANAGER')
    OMBCC '/IGMS_MIS_GEMNCAP_FOC/CURRENTMISTARGET'
    foreach mappingname [OMBLIST MAPPINGS] {
    OMBCREATE TRANSIENT DEPLOYMENT_ACTION_PLAN '$mappingname.DROP' ADD ACTION '$mappingname.DROP' \
    SET PROPERTIES (OPERATION) VALUES ('DROP') SET REFERENCE MAPPING \
    '/IGMS_MIS_GEMNCAP_FOC/CURRENTMISTARGET/$mappingname';}
    foreach mappingname [OMBLIST MAPPINGS] {
    OMBDEPLOY DEPLOYMENT_ACTION_PLAN '$mappingname.DROP'
    OMBCOMMIT;}
    foreach mappingname [OMBLIST MAPPINGS] {
    OMBCREATE TRANSIENT DEPLOYMENT_ACTION_PLAN '$mappingname.CREATE' ADD ACTION '$mappingname.CREATE' \
    SET PROPERTIES (OPERATION) VALUES ('CREATE') SET REFERENCE MAPPING \
    '/IGMS_MIS_GEMNCAP_FOC/CURRENTMISTARGET/$mappingname';}
    foreach mappingname [OMBLIST MAPPINGS] {
    OMBDEPLOY DEPLOYMENT_ACTION_PLAN '$mappingname.CREATE'
    OMBCOMMIT;}

  • Somethig like library

    I want to know this.
    I have a jar with class'(no-application) that I use. Could I deploy this jar in server.After this in application could I use these classes and can to instance they?
    When I try to instance some class ClassLoader of Application connect to ClassLoader of jar and to get instance.
    Is this true or not?
    Thank you very much.

    Features for jdk8:
    http://openjdk.java.net/projects/jdk8/features
    Features from jdk7:
    http://openjdk.java.net/projects/jdk7/features/
    Although both feature lists are pretty long, most changes are technical, specific and back end things which a lot of people never interact with directly.
    The big changes in 8 are lambdas, defender methods and the updated collections interfaces and streaming api, which, taken together allow for use of constructs which originated in functional programming languages, such as map functions, foreach functions, etc. The key concept is that you can replace for loops with functions so that you say do an iteration rather than how to do the iteration. There are two reasons to do this. The first is that you can apply a concept like a spliterator to split apart an iteration and perform it in parallel. The second is that you are programming with higher level constructs like map, filter, fold, etc which results in more concise, less error prone code.

  • ForEach Loop Container Mapping Variable From SSIS Package Not Working In SQL-Server StoredProcedure

    I have an SSIS package that uses a ForEach Loop Container to enumerate Excel Files in a dir. I also have a Task Flow that inserts data from those Excel files into SQL-Server.
    Im trying to insert the file names into a column into the same table in SQL-Server by using a mapping variable in my StoredProcedure.
    Im having trouble with my MappingVariable at the end of the script with red squigglies. The following is my StoredProcedure script.
    CREATE PROCEDURE [dbo].[Insert_F_STG_v2]
    -- Add the parameters for the stored procedure here
    @Hrs float,
    @Type nvarchar(100),
    @SN nvarchar(100),
    @Op nvarchar(100),
    @[USER::CurrentFileName]
    AS
    BEGIN
    SET NOCOUNT ON;
    INSERT INTO [CRM_RC].[dbo].[F_StgTbl]
    [Hrs],
    [Type],
    [SN],
    [Op],
    [Report_Date]
    VALUES
    @Hrs ,
    @Type,
    @SN,
    @Op,
    @[USER::CurrentFileName]
    END
    The last @[USER::CurrentFileName] in the Values block at the bottom of the script is the one giving me issues.
    The following is the error:
    Msg 102, Level 15, State 1, Procedure Insert_F_STG_v2, Line 95
    Incorrect syntax near 'USER::CurrentFileName'.

    This seems to be the solution, but get the following exception: 
    [Derived Column [2]] Error: The "Derived Column" failed because truncation occurred, and the truncation row disposition on "Derived Column.Outputs[Derived Column Output].Columns[Derived Column 1]" specifies failure on truncation. A truncation error occurred
    on the specified object of the specified component.
    AND:  [SSIS.Pipeline] Error: SSIS Error Code DTS_E_PROCESSINPUTFAILED.  The ProcessInput method on component "Derived Column" (2) failed with error code 0xC020902A while processing input "Derived Column Input" (3). The identified component returned
    an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.  There may be error messages posted before this with more information about the failure.

  • ForEach sort on Map values

    Hi,
    Is there any way to sort a map values using ForEach droplet.
    Thanks,

    Could you pls explain a little bit more.In order to sort Map elements by key, set the value as follows:
    {+|-}_key
    For example:
    <dsp:param name="sortProperties" value=" _key"/>See sortProperties section:
    http://docs.oracle.com/cd/E23095_01/Platform.93/PageDevGuide/html/s1316foreach01.html
    -RMishra

  • The new "foreach" statement and maps

    The new "foreach" statement requires an object that implements the java.lang.Iterable<T> interface.
    But why do not extend "for" for accepting objects that implements the Map interface?
    Map<String,String> m = new TreeMap<String,String>();
    for (String key, String value : m) {
         System.out.println (key + "=" + value);   
    }The current alternative
    Map<String,String> m = new TreeMap<String,String>();
    for (Map.Entry<String,String> e : m.entrySet()) {
         System.out.println (e.getKey() + "=" + e.getValue());   
    }is not so clean.

    The new "foreach" statement requires an object that
    implements the java.lang.Iterable<T> interface.Incidentally, I believe "foreach" also allows an object that is an array.
    But why do not extend "for" for accepting objects that
    implements the Map interface?I think that the use of "Iterable" is a very good idea. The interface contains just one method (iterator) and that method is inherently linked to the concept of "foreach". This means anyone can write their own class that implements Iterable, and their class can then be used with "foreach".
    If we specified that "foreach" also worked with Map (with its umpteen methods, only one of which (entrySet) is relevant to "foreach"), this would prevent people writing their own classes which iterate through pairs of values (unless those classes happened to implement Map).
    Ideally, there would be a new interface Pair<A,B> in java.lang (with getFirst() and getSecond() methods), and then if the compiler came across something like this:
        for (String str, Widget widget : items) { ... }where items is an instance of Iterable<Pair<String,Widget>>, then for each iteration, the "Pair" would be split into its component parts and stored in the variables "str" and "widget".
    Unfortunately, it would be difficult to retrofit this concept to java.util.Map, since it would require Map to introduce a new method:
    interface Map<K,V> extends Iterable<Pair<K,V>> {
        Iterator<Pair<K,V>> iterator();
    }and Map.Entry would need to extend Pair, and therefore introduce two new methods:
    interface Entry<K,V> extends Pair<K,V> {
        K getFirst();
        V getSecond();
    }Both of these changes would break huge amounts of existing code that uses Map or Map.Entry.
    Maybe one for Java 3 :)
    Geoff

  • 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

  • Please Help::How to display a Map with LIsts as Keys and Values using JSTL

    Hi,
    I need some assistance on how to display a Map in JSP using struts or core JSTL. I have a HashMap which has a List of keys and each key maps to a value of an ArrayList.i.e I have an ArrayList of taxCodes and each taxCode maps to a value of taxDetails which is an ArrayList of details for for that particular taxCode. I have some trouble to display each taxCode then display taxDetails for each taxCode. Here is my code below:
    OrderDetails.java
    package orderitems;
    import java.sql.*;
    import java.util.*;
    public class OrderDetails {
        private LineOder lineOrder;
        private Map lineItems;
        //returns an item number, key_item, from its unique keys
        public int getItemNumber(int key_item, String key_year,
                String key_office,String key_client,String key_company){
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            int itmNum = 0;
             * key_item a unique number for an item.
             * key_year,key_office,key_client,key_company unique keys
             * for each order where this key_item is taken
             * from.
            String select = "SELECT key_item FROM "+
                    Constants.WEB_TABLE +" WHERE key_item = " + key_item +
                    " AND key_year = '" + key_year + "'" +
                    " AND key_office = '" + key_office + "'" +
                    " AND key_client = '" + key_client + "'" +
                    " AND key_company = '" + key_company +"'";
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                rst = stat.executeQuery(select);
                if(rst.next()){
                    itmNum = Integer.parseInt(rst.getString("key_item"));
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            return itmNum;
        //get a list of item number(item codes)
        public List getAllItemNumbers(String key_year,
                String key_office,String key_client,String key_company){
            List itemNumbers = new ArrayList();
            LineItem itemNumber = null;
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            String select = "SELECT key_item FROM "+ Constants.WEB_TABLE +
                    " WHERE key_year = '" + key_year + "'" +
                    " AND key_office = '" + key_office + "'" +
                    " AND key_client = '" + key_client + "'" +
                    " AND key_company = '" + key_company + "'";
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                rst = stat.executeQuery(select);
                while(rst.next()){
                    itemNumber = new LineItem();
                    itemNumber.setKey_item(Integer.parseInt(rst.getString("key_item")));
                    itemNumbers.add(itemNumber);
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            return itemNumbers;
        //get a list of tax codes
        public List getAllTaxCodes(int key_item, String key_year,
                String key_office,String key_client,String key_company){
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            ItemTax taxCode;
            List taxCodes = new ArrayList();
            int itemNum = getItemNumber(key_item, key_year,
                    key_office,key_client,key_company);
            String select = "SELECT key_tax_code FROM "+
                    Constants.WEB_TABLE +" WHERE key_item = " + itemNum +
                    " AND key_year = '" + key_year + "'" +
                    " AND key_office = '" + key_office + "'" +
                    " AND key_client = '" + key_client + "'" +
                    " AND key_company = '" + key_company +"'";
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                rst = stat.executeQuery(select);
                while(rst.next()){
                    taxCode = new ItemTax();
                    taxCode.setKey_tax_code(rst.getString("key_tax_code"));
                    taxCodes.add(taxCode);
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            return taxCodes;
        /////This methode returns a Map which am trying to display in JSP
        //use tax code to get tax details
        public Map getItemTaxDetails(String key_year,String key_office,
                String key_client,String key_company,int key_item){
            ItemTax taxDetail = null;
            List taxDetails = new ArrayList();
            List itemTaxCodes = new ArrayList();
            Map itemTaxDetails = new HashMap();
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            //get a list of all tax codes of an item with a
            //given item number
            itemTaxCodes = getAllTaxCodes(key_item,key_year,
                    key_office,key_client,key_company);
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                for(Iterator taxCodeIter= itemTaxCodes.iterator(); taxCodeIter.hasNext();){
                    ItemTax itemTaxCode = (ItemTax)taxCodeIter.next();
                    String taxCode = itemTaxCode.getKey_tax_code();
                    String select = "SELECT tax_type,tax_value," +
                            "tax_limit_val FROM "+ Constants.WEB_TABLE +
                            " WHERE key_item = "+ key_item +
                            " AND key_year = '" + key_year + "'" +
                            " AND key_office = '" + key_office + "'" +
                            " AND key_client = '" + key_client + "'" +
                            " AND key_company = '" + key_company +"'" +
                            " AND key_tax_code = '" + taxCode + "'";
                    rst = stat.executeQuery(select);
                    while(rst.next()){
                        taxDetail = new ItemTax();
                        //records to be displayed only
                        taxDetail.setKey_item(Integer.parseInt(rst.getString("key_item")));
                        taxDetail.setTax_value(rst.getString("tax_value"));
                        taxDetail.setTax_limit_val(Float.parseFloat(rst.getString("tax_limit_val")));
                        //////other details records ommited//////////////////////////
                        taxDetails.add(taxDetail);////An ArrayList of taxDetails for each taxCode
                     * A HashMap which has all taxCodes of an item as its keys
                     * and an ArrayList of taxdetails as its values.
                     * I return this for display in a JSP.
                    itemTaxDetails.put(taxCode,taxDetails);
                System.out.println();
                System.out.println("*********CONSOLE OUTPUT*************");//display on console
                Set set = itemTaxDetails.keySet();
                Iterator iter = set.iterator();
                System.out.println("Key\t\tValue\r\n");
                while (iter.hasNext()) {
                    Object taxCode=iter.next();
                    Object details=itemTaxDetails.get(taxCode);
                    System.out.println(taxCode +"\t" + details);
                System.out.println("************************************");
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            return itemTaxDetails;
        //details of an item with all its taxes
        public List getAllItemDetails(String key_year,
                String key_office,String key_client,String key_company){
            List lineItems = new ArrayList();
            List itemNumbers = new ArrayList();
            Map taxDetails = new HashMap();
            LineItem item = null;
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            //A list of all item numbers in the declaration
            itemNumbers = getAllItemNumbers(key_year,
                    key_office,key_client,key_company);
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                for(Iterator itemIter= itemNumbers.iterator(); itemIter.hasNext();){
                    LineItem itemNum = (LineItem)itemIter.next();
                    int itemNumber = itemNum.getKey_item();
                    String select = "SELECT item_description,item_mass," +
                            "item_cost" +
                            " FROM " + Constants.WEB_TABLE +
                            " WHERE key_year = '"+key_year+"'" +
                            " AND key_office = '"+key_office+ "'"+
                            " AND key_client = '"+key_client+ "'"+
                            " AND key_company = '"+key_company+ "'"+
                            " AND key_item = " + itemNumber;
                    rst = stat.executeQuery(select);
                    while(rst.next()){
                        item = new LineItem();
                        item.setItem_description(rst.getString("item_description"));
                        item.setItem_mass(Float.parseFloat(rst.getString("item_mass")));
                        item.setKey_item(Integer.parseInt(rst.getString("item_cost")));
                        //////other details records ommited//////////////////////////
                        /* A HashMap of all itemTaxeCodes as its keys and an
                         * ArrayList of itemTaxedetails as its values
                        taxDetails = getItemTaxDetails(item.getKey_year(),item.getKey_office(),
                                item.getKey_client(),item.getKey_company(),item.getKey_item());
                        //item tax details
                        item.setItmTaxes(taxDetails);
                        //list of items with tax details
                        lineItems.add(item);
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            return lineItems;
        public Set getOrders(String key_year,String key_office,
                String key_client,String key_company){
            List lineItems = new ArrayList();
            Set lineOrders = new HashSet();
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            LineOder lineOrder = null;
            String select = "SELECT * FROM " + Constants.WEB_TABLE +
                    " WHERE key_year = '" + key_year + "'" +
                    " AND key_office = '" + key_office + "'" +
                    " AND key_client = '" + key_client + "'" +
                    " AND key_company = '" + key_company + "'";
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                rst = stat.executeQuery(select);
                while(rst.next()){
                    lineOrder = new LineOder();
                    lineOrder.setKey_year(rst.getString("key_year"));
                    lineOrder.setKey_office(rst.getString("key_office"));
                    lineOrder.setKey_client(rst.getString("key_client"));
                    lineOrder.setKey_company(rst.getString("key_company"));
                    ////list of items with all their details
                    lineItems = getAllItemDetails(lineOrder.getKey_year(),lineOrder.getKey_office(),
                            lineOrder.getKey_client(),lineOrder.getKey_company());
                    //setting item details
                    lineOrder.setItems(lineItems);
                    //a list of order with all details
                    lineOrders.add(lineOrder);
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            return lineOrders;
    Controller.java
    package orderitems;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Controller extends HttpServlet {
        private Map taxDetails = new HashMap();
        private OrderDetails orderDetails = null;
        protected void processRequest(HttpServletRequest request,
                HttpServletResponse response)throws
                ServletException, IOException {
            response.setContentType("text/html;charset=UTF-8");
            String key_year = "2007";
            String key_office = "VZX00";
            String key_company = "DG20";
            String key_client =  "ZI001";
            int key_item = 1;
            String nextView = "/taxdetails_list.jsp";
            orderDetails = new OrderDetails();
            taxDetails = orderDetails.getItemTaxDetails(key_year,key_office,
                    key_company,key_client,key_item);
            //Store the collection objects into HTTP Request
            request.setAttribute("taxDetails", taxDetails);
            RequestDispatcher reqstDisp =
                    getServletContext().getRequestDispatcher(nextView);
            reqstDisp.forward(request,response);
        protected void doGet(HttpServletRequest request,
                HttpServletResponse response)throws
                ServletException, IOException {
            processRequest(request, response);
        protected void doPost(HttpServletRequest request,
                HttpServletResponse response)throws
                ServletException, IOException {
            processRequest(request, response);
    taxdetails_list.jsp
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <title>Simple Tax Detail Diaplay ::</title>
            <link rel="stylesheet" type="text/css" href="imgs/orders.css"/>
        </head>
        <body>
            <jsp:useBean id="taxDetails" class="java.util.HashMap" scope="request"/>
            <table>
                <c:forEach items="${taxDetails}" var="hMap">
                    <tr>
                        <td><c:out value="${hMap.key}" /></td>
                        <!--td><%--c:out value="${hMap.value}" /--%></td-->
                    </tr>
                </c:forEach>
            </table>
        </body>
    </html>am displaying taxCodes(in this case i have VAT and ICD) fine but cant figure out how to display a list of value for each taxCode.Here is the output am getting
    both in my JSP and on the console:
    *******************************CONSOLE OUTPUT****************************
    Key          Value
    ICD     [orderItems.ItemTax@13e6226, orderItems.ItemTax@9dca26]
    VAT [orderItems.ItemTax@13e6226, orderItems.ItemTax@9dca26]
    Edited by: aiEx on Oct 8, 2007 6:54 AM

    hi evnafets,
    yes i need a nested for loop.I have tried your advice but my bean properties are not found.Am getting this error:
    javax.servlet.ServletException: Unable to find a value for "key_item" in object of class "java.lang.String" using operator "."
    I have tried this as stated earlier in the post:I have tried to make the method getItemTaxDetails return a List and get the returned list value as taxDetails. I then tested to display this list on JSP and its displaying fine.
    public List getItemTaxDetails(String key_year,String key_office,
                String key_client,String key_company,int key_item){
            ItemTax taxDetail = null;
            List taxDetails = new ArrayList();
            List itemTaxCodes = new ArrayList();
            Map itemTaxDetails = new HashMap();
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            //get a list of all tax codes of an item with a
            //given item number
            itemTaxCodes = getAllTaxCodes(key_item,key_year,
                    key_office,key_client,key_company);
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                for(Iterator taxCodeIter= itemTaxCodes.iterator(); taxCodeIter.hasNext();){
                    ItemTax itemTaxCode = (ItemTax)taxCodeIter.next();
                    String taxCode = itemTaxCode.getKey_tax_code();
                    String select = "SELECT tax_type,tax_value," +
                            "tax_limit_val FROM "+ Constants.WEB_TABLE +
                            " WHERE key_item = "+ key_item +
                            " AND key_year = '" + key_year + "'" +
                            " AND key_office = '" + key_office + "'" +
                            " AND key_client = '" + key_client + "'" +
                            " AND key_company = '" + key_company +"'" +
                            " AND key_tax_code = '" + taxCode + "'";
                    rst = stat.executeQuery(select);
                    while(rst.next()){
                        taxDetail = new ItemTax();
                        //records to be displayed only
                        taxDetail.setKey_item(Integer.parseInt(rst.getString("key_item")));
                        taxDetail.setTax_value(rst.getString("tax_value"));
                        taxDetail.setTax_limit_val(Float.parseFloat(rst.getString("tax_limit_val")));
                        //////other details records ommited//////////////////////////
                        taxDetails.add(taxDetail);////An ArrayList of taxDetails for each taxCode
                     * A HashMap which has all taxCodes of an item as its keys
                     * and an ArrayList of taxdetails as its values.
                     * I return this for display in a JSP.
                    itemTaxDetails.put(taxCode,taxDetails);
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            //return itemTaxDetails;
            return taxDetails;
        }And my JSP
    taxdetails_list.jsp
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <link rel="stylesheet" type="text/css" href="imgs/orders.css"/>
        </head>
        <body>
            <table>
                <c:forEach var="curRecord" items="${taxDetails}" varStatus="rowCounter">
                        <c:choose>
                            <c:when test="${rowCounter.count % 2 == 0}">
                                <c:set var="rowStyle" scope="page" value="odd" />
                            </c:when>
                            <c:otherwise>
                                <c:set var="rowStyle" scope="page" value="even" />
                            </c:otherwise>
                        </c:choose>
                        <tr class="${rowStyle}">
                            <td>${curRecord.key_item}</td>
                            <td>${curRecord.tax_value}</td>
                            <td>${curRecord.tax_limit_val}</td>
                        </tr>
                    </c:forEach>
            </table>
        </body>
    </html>I can't see where am going wrong even with your advice.Please help.
    Thnx.

  • How to modify an EXTERNAL_TABLE and MAPPING using OMBplus

    I need to implement a QA--> Production migration technique using OMB+ scripting. We are using source safe for keeping the MDL files.
    As we have insufficient resources both environments are in the same database as different schemas. Configuration is as below;
    Source Schema: DWPROD_TST (test) and DWPROD (production)
    Target Schema: DWEXTRACT_TST (test) and DWEXTRACT (production)
    Source Flat File Module: DWEXTRACT_TST_INPUT (test) and DWEXTRACT_INPUT (production)
    Target Flat File Module: DWEXTRACT_TST_OUTPUT (test) and DWEXTRACT_OUTPUT (production)
    All schemas have their own locations and modules defined. Once a mapping is create in TST environment developers should check in the individual
    mdl files for the object they used for development. From is point the strategy I have follow is like below as I haven't seen a similar scenario before.
    I rename the mdl extensiton .zip. I unzip the file. I take the mdx file extracted and make a text based search/replace for all the test environment modules, locations... etc
    replacing them with production environment names. Then I run the OMB+ script below in order to import and deploy this object. This technique works for table and flat file object
    with slightly different OMB+ scripts. But I can not make it work for external tables and mappings and the reason that I can guess is the Configuration information of the Data File used
    as source for external table and target for the mapping I have developed. I can import the MDX successfully but cant deploy it. When i rigt click the mapping or the external file in OWB GUI
    and click on CONFIGURATION I can see that:
    For the MAPPING : Flat File Operator/(OperatorName)/Target Data File Location is still pointing to TEST environment even tough I have replaced all the TEST environment information with PRODUCTION.
    For the EXTERNAL_TABLE : Data File/(OperatorName)/Data File Location is still pointing to TEST environment even tough I have replaced all the TEST environment information with PRODUCTION.
    Is there any way to modify these LOCATION information for a MAPPING and an EXTERNAL TABLE OMB+. I read though all OWB+ scripting Reference but it sucks or I am so dumb.
    Or if you have an alternative solution for my problem I will be more then happy to read it.
    OMB+ Script for EXTERNAL_TABLE
    OMBCONNECT DWPROD/DWPROD@cakir:1521:orcl USE REPOSITORY 'OWBDB_SYS'
    OMBIMPORT MDL_FILE 'C:\\tfs\\stage\\externaltables\\XTRCT_XTRNL_INPUT_FILE\\XTRCT_XTRNL_INPUT_FILE.mdx' USE UPDATE_MODE MATCH_BY NAMES OUTPUT LOG TO 'C:\\tfs\\stage\\externaltables\\XTRCT_XTRNL_INPUT_FILE\\XTRCT_XTRNL_INPUT_FILE.log'
    OMBCC 'MY_PROJECT'
    OMBCONNECT CONTROL_CENTER
    OMBCOMMIT
    OMBALTER LOCATION 'XTRCT_DWEXTRACT_LOC' SET PROPERTIES (PASSWORD) VALUES ('PASSWORD')
    OMBALTER ORACLE_MODULE 'XTRCT_DWEXTRACT' ADD REFERENCE LOCATION 'XTRCT_DWEXTRACT_LOC' SET AS DEFAULT
    OMBALTER ORACLE_MODULE 'XTRCT_DWEXTRACT' SET PROPERTIES (DB_LOCATION) VALUES ('XTRCT_DWEXTRACT_LOC')
    OMBCOMMIT
    OMBREGISTER LOCATION 'XTRCT_DWEXTRACT_LOC'
    OMBCOMMIT
    OMBREGISTER LOCATION 'DWEXTRACT_INPUT'
    OMBCOMMIT
    OMBCC 'XTRCT_DWEXTRACT'
    OMBALTER EXTERNAL_TABLE 'XTRCT_XTRNL_INPUT_FILE' SET REFERENCE DEFAULT_LOCATION 'DWEXTRACT_INPUT'
    OMBCOMMIT
    OMBCREATE TRANSIENT DEPLOYMENT_ACTION_PLAN 'DEPLOY_PLAN' ADD ACTION 'TABLE_DEPLOY' SET PROPERTIES (OPERATION) VALUES ('REPLACE') SET REFERENCE EXTERNAL_TABLE 'XTRCT_XTRNL_INPUT_FILE'
    OMBDEPLOY DEPLOYMENT_ACTION_PLAN 'DEPLOY_PLAN'
    OMBDROP DEPLOYMENT_ACTION_PLAN 'DEPLOY_PLAN'
    OMBCOMMIT
    OMBDISCONNECT
    OMB+ Script for the mapping
    OMBCONNECT DWPROD/DWPROD@cakir:1521:orcl USE REPOSITORY 'OWBDB_SYS'
    OMBIMPORT MDL_FILE 'C:\\tfs\\stage\\mappings\\XTRCT_PROTOTYPE_XTRCTFILE_000\\XTRCT_PROTOTYPE_XTRCTFILE_000.mdx' USE UPDATE_MODE MATCH_BY NAMES OUTPUT LOG TO 'C:\\tfs\\stage\\mappings\\XTRCT_PROTOTYPE_XTRCTFILE_000\\XTRCT_PROTOTYPE_XTRCTFILE_000.log'
    OMBCC 'MY_PROJECT'
    OMBCONNECT CONTROL_CENTER
    OMBCOMMIT
    OMBALTER LOCATION 'XTRCT_DWEXTRACT_LOC' SET PROPERTIES (PASSWORD) VALUES ('PASSWORD')
    OMBALTER ORACLE_MODULE 'XTRCT_DWEXTRACT' ADD REFERENCE LOCATION 'XTRCT_DWEXTRACT_LOC' SET AS DEFAULT
    OMBALTER ORACLE_MODULE 'XTRCT_DWEXTRACT' SET PROPERTIES (DB_LOCATION) VALUES ('XTRCT_DWEXTRACT_LOC')
    OMBCOMMIT
    OMBALTER LOCATION 'XTRCT_DWPROD_LOC' SET PROPERTIES (PASSWORD) VALUES ('PASSWORD')
    OMBALTER ORACLE_MODULE 'XTRCT_DWPROD' ADD REFERENCE LOCATION 'XTRCT_DWPROD_LOC' SET AS DEFAULT
    OMBALTER ORACLE_MODULE 'XTRCT_DWPROD' SET PROPERTIES (DB_LOCATION) VALUES ('XTRCT_DWPROD_LOC')
    OMBCOMMIT
    OMBREGISTER LOCATION 'XTRCT_DWEXTRACT_LOC'
    OMBCOMMIT
    OMBREGISTER LOCATION 'XTRCT_DWPROD_LOC'
    OMBCOMMIT
    OMBREGISTER LOCATION 'DWEXTRACT_INPUT'
    OMBCOMMIT
    OMBREGISTER LOCATION 'DWEXTRACT_OUTPUT'
    OMBCOMMIT
    OMBCC 'XTRCT_DWEXTRACT'
    OMBCREATE TRANSIENT DEPLOYMENT_ACTION_PLAN 'DEPLOY_PLAN' ADD ACTION 'MAPPING_DEPLOY' SET PROPERTIES (OPERATION) VALUES ('CREATE') SET REFERENCE MAPPING 'XTRCT_PROTOTYPE_XTRCTFILE_000'
    OMBDEPLOY DEPLOYMENT_ACTION_PLAN 'DEPLOY_PLAN'
    OMBDROP DEPLOYMENT_ACTION_PLAN 'DEPLOY_PLAN'
    OMBCOMMIT
    OMBDISCONNECT
    Kind Regards,
    Emrah
    Edited by: cakire82 on Jul 29, 2009 12:57 PM

    If it helps, this is a chunk from a script I have which turned off the parallel loading hint on all targets in a given mapping which was required after we discovered that ANSI cross joins and parallel query do NOT work very well in Oracle 10.
    You can see that I OMBRETREIVE all table operators and then use a foreach loop to cycle through them.
    log_msg LOG  "Altering: $mapName"
    set tablist [OMBRETRIEVE MAPPING '$mapName' GET TABLE OPERATORS ]
    foreach tgt_tble $tablist {
        if [catch { set retstr [ OMBALTER MAPPING '$mapName' MODIFY OPERATOR    '$tgt_tble' SET PROPERTIES (LOADING_HINT) VALUES ('NOPARALLEL ("$mapName")')] } errmsg] {
            log_msg ERROR "Unable to set hint for table $tgt_tble of mapping $mapName "
            log_msg ERROR "$errmsg"
        } else {
            set print [ exec_omb OMBCREATE TRANSIENT DEPLOYMENT_ACTION_PLAN 'DEPLOY_PLAN' ADD ACTION 'MAPPING_DEPLOY' SET PROPERTIES (OPERATION) VALUES ('CREATE') SET REFERENCE MAPPING '$mapName' ]
            if [omb_error $print] {
                 log_msg ERROR "Unable to create Deployment plan for '$mapName'"
            } else {
                  set print [ exec_omb OMBDEPLOY DEPLOYMENT_ACTION_PLAN 'DEPLOY_PLAN' ]
                  if [omb_error $print] {
                      log_msg ERROR "Error on execute of Deployment plan for '$mapName'"
            OMBDROP DEPLOYMENT_ACTION_PLAN 'DEPLOY_PLAN'
            OMBCOMMIT
    }Ignore the exec_omb function as this is just a wrapper I built for OMB+ commands.
    As to passing parameters, look into argc and argv:
    if { $argc > 0 } {
         set i 1
         foreach arg $argv {
              puts "argument $i is $arg"
              incr i
      } else {
         puts "no command line argument passed"
      }You can also write interactive scripts if you prefer too. From earlier in the script above which turned off the parallel hint:
    puts ""
    puts -nonewline "Which mapping do you want to set to NOPARALLEL? "
    set mapName [gets stdin]I've even done loops to allow the user to perform the operation on multiple mappings, and to use pattern matching to determine which mappings to alter:
    set doLoop "1"
    while { [string match "1" $doLoop] } {
        puts -nonewline "What mapping to reconfigure (use name of generated plsql package)? "
        flush stdout
        set mapName [ string toupper [gets stdin] ]
        puts -nonewline "What value do you want to set as the maximum allowed errors? "
        flush stdout
        set eValue [gets stdin]
        set mapList [OMBLIST MAPPINGS '.*$mapName.*']
        if { [llength $mapList] == 0 } {
           log_msg ERROR "No mappings matching search string $mapName"
        } else {
            foreach mName $mapList {
                 puts -nonewline "Update mapping $mName (y/n)? "
                 flush stdout
                 set doThisUpdate [string toupper [gets stdin]]
                if { [string match "Y" $doThisUpdate ] } {
                    if [catch { set retstr [ OMBALTER MAPPING '$mName' SET PROPERTIES (MAXIMUM_NUMBER_OF_ERRORS) VALUES ( '$eValue')] } errmsg] {
                        log_msg ERROR "Unable to modify max errors on Mapping $mName"
                        log_msg ERROR "$errmsg"
                    } else {
                        set print [ exec_omb OMBCREATE TRANSIENT DEPLOYMENT_ACTION_PLAN 'DEPLOY_PLAN' ADD ACTION 'MAPPING_DEPLOY' SET PROPERTIES (OPERATION) VALUES ('CREATE') SET REFERENCE MAPPING '$mName' ]
                        if [omb_error $print] {
                            log_msg ERROR "Unable to create Deployment plan for '$mName'"
                        } else {
                            set print [ exec_omb OMBDEPLOY DEPLOYMENT_ACTION_PLAN 'DEPLOY_PLAN' ]
                            if [omb_error $print] {
                                log_msg ERROR "Error on execute of Deployment plan for '$mName'"
                        exec_omb OMBDROP DEPLOYMENT_ACTION_PLAN 'DEPLOY_PLAN'
                        exec_omb OMBCOMMIT
                } else {
                    log_msg LOG "Skipping update to mapping $mName"
        puts -nonewline "Do Another? (y/n) "
        flush stdout
        set doAnother [gets stdin]
        if { [string match "Y" [string toupper $doAnother] ] } {
            log_msg LOG "User requests more updates"
        } else {
            set doLoop "0"
    }Anyway - there is lots that you can do to parameterize script or make them interactive. Just spend a bit of time working through a couple of TCL tutorials and you'll be well on your way.
    +(Note: script chunks have been edited for clarity of the main point I wanted to illustrate and may contain missmatched braces or other syntax problems.)+

  • [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

  • How do you extract data from ArrayList of Maps and the classical Iterator?

    Hello guys.
    I ran into this great doozie when I was coding this project I am working on. I have created a randomized question pool for a test so that no two tests with the same ID are alike. I grab a resultset from the DB and push the values through a randomizer. After that, then I stick a Map of the entire object into an ArrayList. Each object is then one complete question. So I have X objects (questions) in the ArrayList then (this is determined by a value in the DB in the test table).
    I have the following code setup:
    Map m = (Map)i.next();
              Iterator keys = m.keySet().iterator();
              while (keys.hasNext())
                   key = keys.next();
                   value = (String)m.get(key);
    The key - data pair always comes out in the same order. What I am trying to do is populate a test (form values) for this. Is there a way that I can do this in JSP? The key map is 100% new to me.
    I want to put the test into a table layout. the typical HTML boiler plate stuff is a cinch, but how would I get the information into a textfield? I can print out the key value pairs, but I guess I get lost in the logic when trying to get these to print in a specific order. Any help you can provide would be highly appreciated.
    Kind Regards,
    Josh

    You can use the JSTL c:forEach tag for that.

  • Mapping a one to many relationship using fluent api

    Hi I can't map my domains to match the database, since database is already created, I can't create or remove any other extra table.
    Database
    CREATE TABLE PLAYER (Id Int, Name varchar(100), PRIMARY KEY (Id))
    CREATE TABLE POSITION (Id Int, Name varchar(100), PRIMARY KEY (Id))
    CREATE TABLE CHAMPIONSHIP (Id Int, Name varchar(100), PRIMARY KEY (Id))
    CREATE TABLE RELATED (PlayerId Int, PositionId Int, ChampionshipId int,
    FOREIGN KEY (PlayerId) references PLAYER(id),
    FOREIGN KEY (PositionId) references POSITION(id),
    FOREIGN KEY (ChampionshipId) references CHAMPIONSHIP(id),
    CONSTRAINT AK_RELATED UNIQUE(PlayerId,PositionId,ChampionshipId))
    Domains:
    public class Player
    public Player()
    this.Relateds = new List<Related>();
    public int Id {get;set;}
    public string Name { get; set; }
    public virtual ICollection<Related> Relateds { get; set; }
    public class Position
    { public int Id {get;set;}
    public string Name { get; set; } public virtual ICollection<Related> Relateds { get; set; }
    public class Championship
    { public int Id {get;set;}
    public string Name { get; set; } public virtual ICollection<Related> Relateds { get; set; }
    public class Related
    public int PlayerId { get; set; }
    public Player Player{ get; set; }
    public int PositionId { get; set; }
    public Position Position { get; set; }
    public int ChamionshipId { get; set; }
    public Championship Championship { get; set; }
    FLUENT API:
    modelBuilder.Entity<Player>().HasKey(m => m.Id);
    modelBuilder.Entity<Player>().Property(m => m.Name).IsRequired();
    modelBuilder.Entity<Position>().HasKey(m => m.Id);
    modelBuilder.Entity<Position>().Property(m => m.Name).IsRequired();
    modelBuilder.Entity<Championship>().HasKey(m => m.Id);
    modelBuilder.Entity<Championship>().Property(m => m.Name).IsRequired();
    Seed.cs
    public DbSet<Player> Players { get; set; }
    public DbSet<Position> Positions { get; set; }
    public DbSet<Championship> Championships { get; set; }
    private void Seed2(ApplicationDbContext context)
    string[] playerNames = new string[] { "Adam", "John", "Lucas" };
    string[] positionNames = new string[] { "Sniper", "Camper", "Assalt" };
    string[] championshipNames = new string[] { "BF4", "CS1.6", "TF2" };
    int relations = 3;
    try
    foreach (var name in playerNames)
    if (!this.Players.Any(m => m.Name == name))
    Player player = new Player { Name = name };
    context.Players.Add(player);
    foreach (var name in positionNames)
    if (!this.Players.Any(m => m.Name == name))
    Position position = new Position { Name = name };
    context.Positions.Add(position);
    foreach (var name in championshipNames)
    if (!this.Championship.Any(m => m.Name == name))
    Championship championship = new Championship { Name = name };
    context.Championships.Add(championship);
    context.SaveChanges();
    for (int i = 1; i <= relations; i++)
    var player = context.Players.ToList()[i];
    var position = context.Positions.ToList()[i];
    var championship = context.Championships.ToList()[i];
    if (!context.Relateds.Any(m =>
    context.Players.Any(t => m.PlayerId == t.Id)
    && context.Positions.Any(t => m.PositionId == t.Id)
    && context.Championships.Any(t => m.ChampionshipId == t.Id)))
    Related related = new Related
    Player = player,
    Position = position,
    Championship = championship
    player.Relateds.Add(related);
    context.Entry(player).State = EntityState.Modified;
    context.SaveChanges();
    catch (Exception ex)
    throw;
    I'm not able to insert into the Related table, I think the fluent api is not maped well, how can I fix it?

    Hello,
    >>I'm not able to insert into the Related table, I think the fluent api is not maped well, how can I fix it?
    As you mentions, your database already exists, so I assume that you are using database first approach, then, as far as I know, the fluent API is made only for Code-First approach and we don't need the fluent API if we create your model via Database-First.
    For database first approach, we just need to import existed tables to the designer surface by “Update Model From Database”. And with your provided model, I noticed that the related table does not contain a primary constraint, in Entity Framework, a table
    without the primary key would be treated as a view that is read only. So please create a primary constraint for the related table as:
    CREATE TABLE RELATED (PlayerId Int, PositionId Int, ChampionshipId int,
    FOREIGN KEY (PlayerId) references PLAYER(id),
    FOREIGN KEY (PositionId) references POSITION(id),
    FOREIGN KEY (ChampionshipId) references CHAMPIONSHIP(id),
    PRIMARY KEY CLUSTERED (PlayerId ASC, PositionId ASC,ChampionshipId asc),
    CONSTRAINT AK_RELATED UNIQUE(PlayerId,PositionId,ChampionshipId))
    With your provided tables, after adding this constraint, the Related table could add a new row as:
    using (DFDBEntities db=new DFDBEntities())
    RELATED related = new RELATED() { PlayerId = 1, ChampionshipId = 1, PositionId = 1 };
    db.RELATEDs.Add(related);
    db.SaveChanges();
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for

  • MHKIM:AP PAYMENT TYPE인 QUICK(약식)과 MANUAL(수동)의 차이점

    제품: FIN_AP 작성날짜 : 2006-10-17 AP PAYMENT TYPE인 QUICK(약식)과 MANUAL(수동)의 차이점 =========================================== PURPOSE Payment Type에서 QUICK(약식)과 MANUAL(수동)의 차이가 무엇인가요? Explanation 두 type간의 차이는 infra의 차이라고 말씀드릴 수 있겠습니다. 일반적으로 지급을 하면, 승인을 하고, For

  • Orcale Vs. SAP "Clear GL open items" ?

    Dears, I am new to oracle, previously I was using SAP, and I wonder if oracle have the same capability to view the GL entries as open items (non cleared entries), and if there is any possibility to clear B/S GL accounts. "such feature in SAP is calle

  • AppleTV + iPhone randomly stops playing music.

    My dad bought a appletv a few days ago and i set it up in his living room, about 40 feet from the wireless router, and it has 4 bars in the wireless settings menu. Everything is working fine, except when playing music to the appletv over airplay, it

  • What is the best place to do an iphone speed test?

    What is the best place to do an iphone speed test? I hear some sites are not so accurate. I ask because i would always have speeds above 750 kbps but now im not getting more than 400kbps after i updated to 2.0.2 . I just wanna double check that my sp

  • [flash mx 2004] c'est un bug ou c'est moi ?

    Salut, J'ai un truc bizarre qui se produit dans un script. Voil� le probl�me (apr�s simplification du code) : - j'ai un mc nomm� "test" - j'ai le code ci-dessous dans la 1ere frame - le comportement est normal pour les zone haut/gauche et bas/droite