Dynamic Connections

  • Hello All,

    I have a package that downloads a lot of csv files and transfers their contents into a database. For one of the tasks in this package, I have a Precedence Constraint that evaluates the following expression:

    @Table_Number == "3290056" || @Table_Number == "3290057" || @Table_Number == "3290058" || @Table_Number == "3290059" || @Table_Number == "3290060" || @Table_Number == "3290061" || @Table_Number == "3290062" || @Table_Number == "3290063" || @Table_Number == "3290064" || @Table_Number == "3290065" || @Table_Number == "3290066" || @Table_Number == "3290067" || @Table_Number == "3290068" Basically what happens up to this is:

    1. Download data based on a tblRelease_Dates query (if release is today, download).

    2. Unzip the file (extract the csv)

    3. Set the final destination path to archive the zipped files.

    4. Start transform and load processes.

    My problem is when the process flows get to the above precedence constraints. The previous line I gave checks which table is being transferred and loaded. However, I need to extract from the file in the folder with which-ever Table_Number is called. In the next step, I need to connect to the csv files and then load the values into a staging table. In the folder, the file name looks like: 3290056-eng.csv, 3290057-eng.csv, ..., & 3290068-eng.csv. If I do this the way I've learned, which is to create a connection using the connection manager, it will not be a dynamic connection so no matter which table number I'm on, it will only connect to the connection I make. How can I create a dynamic connection based on the table numbers. I'm going to play around in the Script Task sandbox to try and figure this out but I thought in the meantime I would ask first.

    Regards:
    Mordred
    Keep on Coding in the Free World

  • My understanding is that there is not the ability to have dynamic connections. I have split packages into mult pkgs to get around it.

  • Seriously? Darn! Now I'll have to make 11 different packages? Darn!

    Regards:
    Mordred
    Keep on Coding in the Free World

  • Can you answer a couple more questions about your set-up:

    1) Is the file format the same for all files?

    2) Is this a common staging table, or is there one staging table per file to be imported?

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • If by format you mean the type of file then yes, they are all CSVs. If you mean the format in the csv then no, they all differ a bit (column names may differ).

    The staging table is a common staging table that is set up to accommodate all the csvs (at least so far it is).

    Regards:
    Mordred
    Keep on Coding in the Free World

  • I've been working on a workaround for this. I've created individual connections for each CSV file. At a certain point in my package, and while using precedence constraints for each table, I have been able to connect to each file individually for my ETL processes. the attachment sort of shows.

    Regards:
    Mordred
    Keep on Coding in the Free World

  • Mordred (5/15/2013)


    I've been working on a workaround for this. I've created individual connections for each CSV file. At a certain point in my package, and while using precedence constraints for each table, I have been able to connect to each file individually for my ETL processes. the attachment sort of shows.

    I think you're working along the right lines: check what sort of file it is and then execute the appropriate data flow - though I think I would have expected to see more things happening within the Foreach container.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • I only showed a small part of the For loop container. Check the new image out to see that I'm doing a fair bit in there and I'm still adding.

    Also, and this still has to do with connections, I got the following error when I started this up this morning:

    Error1Error loading DownloadCSVPackage.dtsx: The connection "" is not found. This error is thrown by Connections collection when the specific connection element is not found. C:\Projects\EconAnalysisStatsCan\EconAnalysisStatsCan\DownloadCSVPackage.dtsx

    I don't know how to find this blank connection, any ideas? I've scrolled my Connection Manager pane and don't see an connections named "".

    EDIT: I've finished the workflow but I'm still seeing issues regarding the connection with a name "".

    Regards:
    Mordred
    Keep on Coding in the Free World

  • I've had that error when there's no value in the connection string

    You'll need a default connection even if you are setting the actual connection with an expression that evaluates at runtime.

    I have a similar sounding job which is a set of packages that import about four hundred csv files daily from four different business section zip file imports (from our outsourced business system) and the same file name and format is in each section i.e. file salsorders.csv will be the same format in each business section.

    I use script tasks at the start to set up the correct import, error log and zip archive folders into variables and then a for each section number loop which does the import to combined staging tables which the next package converts and loads to live.

    The connection string of a flat file is then an expression such as import folder variable plus file name plus section number variable plus extension.

    I split the import section into sub-packages due to the slowness of working on each package and the whole thing is far more manageable. The dtutil batch script to deploy the packages is my most time saving utility!

  • You'll need a default connection even if you are setting the actual connection with an expression that evaluates at runtime.

    Where do I set the default connection? I'm going to start looking now and will post an answer when I find it but if someone posts before I do I'm going to keep checking here.

    Regards:
    Mordred
    Keep on Coding in the Free World

  • Mordred (5/21/2013)


    You'll need a default connection even if you are setting the actual connection with an expression that evaluates at runtime.

    Where do I set the default connection? I'm going to start looking now and will post an answer when I find it but if someone posts before I do I'm going to keep checking here.

    I think that the poster means the design-time value of the variable which the connection uses - as can be seen in the Variables window.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply