Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2012
    Posts
    5

    IF Select statement syntax issue

    I am using SSIS and DB2. I have db2 query IF....Select query as follows:

    if 'a'='a' then
    select count(*) from x;
    elseif 'b'='b'
    select count(*)from y;
    else
    select count(*) from z;
    end if

    Somehow this is not working neither on db2 client nor on ssis. Can anyone suggest would could be wrong with this?

    Thanks,
    hs

  2. #2
    Join Date
    Aug 2008
    Location
    Toronto, Canada
    Posts
    2,361
    Quote Originally Posted by harry001 View Post
    this is not working
    Quoting n_i on this forum -> "It does not work" is not a valid problem statement.


    What is 'a'='a', 'b'='b'... ? Where does a and b come from? a=a and b=b will always be true. How do you execute this sql on db2 client? From command line?

  3. #3
    Join Date
    Jul 2012
    Posts
    5
    Quote Originally Posted by db2girl View Post
    Quoting n_i on this forum -> "It does not work" is not a valid problem statement.


    What is 'a'='a', 'b'='b'... ? Where does a and b come from? a=a and b=b will always be true. How do you execute this sql on db2 client? From command line?
    Actually, I am using this code in ssis for each loop container. Now I have to iterate through number of rows in a result set of the container. Therefore, I have a variable that has table name. So I am saying:
    IF var::Table name='Quick response' then
    select count(*)......
    elseif var::Table name='AccomadationLog' then
    select count(*).......
    else
    select count(*).....
    end if

    So, 'a' and 'b' were variables and their value was coming from ssis. When this sql was run in IBM data studio, it doesnt provide any results?

    Thanks,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •