If -Then Statement

  • Hi,

    I am pretty new working with SSIS, I was not sure if this is the right place to post a question, If it is not please forgive beforehand.

    I have a store procedure that needs to be converted into an ETL package. The snippet of code that I am trying to deal with goes like this

    LANGUAGE NZPLSQL AS

    BEGIN_PROC

    DECLARE

    maxtrans integer ;

    newtrans integer ;

    BEGIN

    IF SP_CHK_IF_TABLE_EXISTS('MY_TABLE_NAME')

    THEN

    maxtrans := NVL(MAX(transactionid),0) FROM 'MY_TABLE_NAME';

    ELSE

    maxtrans = 123456789;

    END IF;

    Basically it calls an existing SP to check if the table exists in the DB.

    If it does exist it gets the Max transaction ID

    If it does not exist assigns the maxtrans(transID)

    Later down the execution of the package we will use the two variables set at the beginning of the stored procedure

    select

    column,

    max(column) column,

    max(column) column,

    transactionid

    from MYTABLE

    where transactionid > 1234567

    group by transactionid

    Due to new management, we are migrating existing ETL that did some the work at a SP level and putting some of the work load into our ETL server.

    Any help will be greatly appreciated and again, if I am in the wrong place I’d appreciate if you guys can direct me to the right forum

    Thanks

  • pchelptx (12/3/2014)


    I am pretty new working with SSIS, I was not sure if this is the right place to post a question, If it is not please forgive beforehand.

    Welcome, and no worries. The forum you want is typically: http://www.sqlservercentral.com/Forums/Forum364-1.aspx, just for future reference. No harm done though.

    I have a store procedure that needs to be converted into an ETL package. The snippet of code that I am trying to deal with goes like this

    LANGUAGE NZPLSQL AS

    Always fun, but keep in mind that the optimal path is not always to rewrite everything. Sometimes you simply use SSIS as a programatical container for chained database calls.

    Also, NZPLSQL? You're trying to connect to Netezza (form of Postgres)? Um. Ew.

    Start with basics. Can you create/connect via ODBC from the SQL/SSIS box to Netezza? You're going to need that, and offhand I'm not sure what drivers you need. I'm not sure how much help I can give you here beyond a few ideas.

    BEGIN_PROC

    DECLARE

    maxtrans integer ;

    newtrans integer ;

    BEGIN

    IF SP_CHK_IF_TABLE_EXISTS('MY_TABLE_NAME')

    THEN

    maxtrans := NVL(MAX(transactionid),0) FROM 'MY_TABLE_NAME';

    ELSE

    maxtrans = 123456789;

    END IF;

    Basically it calls an existing SP to check if the table exists in the DB.

    If it does exist it gets the Max transaction ID

    If it does not exist assigns the maxtrans(transID)

    I'd stuff this code, with minor modifications, into an ExecuteSQL task. Have it return a single row (SELECT maxtrans, newtrans) at the tail and stuff that into a result set for variables assigned to each column.

    select

    column,

    max(column) column,

    max(column) column,

    transactionid

    from MYTABLE

    where

    transactionid > 1234567

    group by

    transactionid

    This looks like another call to your Netezza db, but instead as the source in a dataflow. Look up parameters in google and it'll walk you through. Basically it's a series of swapping out values for question marks (ie: transactionID > ?) and feeding the variable in via the parameters button.

    Not sure where you're trying to send this though, so I can't recommend anything besides the generic method.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • Thanks for your help. Our DW runs on Netezza. I don't have any issues connecting to it from SSIS. I am still having a hard time understanding the entire process. I'm gonna go ahead and give your approach a shot.

    Thanks again

Viewing 3 posts - 1 through 2 (of 2 total)

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