locked
Opalis - joing two paralel executions and using data from both RRS feed

  • Question

  • Hi,

    Ive run into an issue, wether it can be done this way, i dont know - this is my first attempt of creating a work flow.

    I have a csv file, that i want to import into a database, 1st line contains the field names.

    Step 1 : a "query database" component, this deletes the content of the table
    Step 2: "Read line" component, this reads the file, line by line

    from here on, its gets a bit complicated...

    two links step 2
    link a: links to step 3a, with line number = 1
    link b: links to step 3b, with line number > 1

    Step 3a: "Replace text" - this replaces ; characters to ,

    Step 3b: "Replace text" - this replaces ; characters to ','

    From here im kinda stuck.

    i would think i need a junction to republish data from step 3b and link it to a "query database" that does the physical insert.

    it gets the data from Step3b just fine - but i can not get the data from 3a, which contains the field names to fill the query

    how do i do this? how do i get this single value from Step 3a back into my flow?

    Thanks for you help.
    /Stig

    Wednesday, May 16, 2012 9:41 AM

Answers

  • Hi,

    So you need info from the file in the SQL query? Then start by Reading only the first line from the file, and use that info in the SQL query. Then you can read the rest of the file in a second activity and write it to the database


    Anders Bengtsson | Microsoft PFE | blog at http://www.contoso.se

    Wednesday, May 23, 2012 3:45 PM

All replies

  • If you want to clear the database and then read a CSV file and import all the data into a database, you can do

    1. Query Database (clear Everything in the database)

    2. Read Line. The CSV file, start read on line 2, Lines = 2-END

    3. Query Database. A SQL Query to insert the data into sql. Here you can use the data manipulation feature to split the CSV file into different fields in the database. For example, lets say you have 3 fields in the CSV file, then you can get them by

    [FIELD('Full Line from Read Line',';',1)]

    We take the full line from the read line activity, we split on ; and we take the first part (1)


    Anders Bengtsson | Microsoft PFE | blog at http://www.contoso.se

    Wednesday, May 16, 2012 4:21 PM
  • Yes - i got that working just fine...

    but then i wanted to expand it, so the workflow would be more dynamic.

    so the filename would describe the tablename and line 1 would contain the fields avabile in the table...

    and there i got stranded.. was thinking about using a gobal variable for this, but it just seems a bit "overkill" to define such a variable...

    Any thoughts?

    Thursday, May 17, 2012 2:35 PM
  • Hi,

    So you need info from the file in the SQL query? Then start by Reading only the first line from the file, and use that info in the SQL query. Then you can read the rest of the file in a second activity and write it to the database


    Anders Bengtsson | Microsoft PFE | blog at http://www.contoso.se

    Wednesday, May 23, 2012 3:45 PM
  • yep - that was what i ended up doing...

    abit strange that apperetly you have to read the file twice... but its working..

    thanks...


    /Stig

    Thursday, May 31, 2012 3:26 PM