If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > IF Select statement syntax issue

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #2 (permalink)  
Old
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 2,357
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?
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
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,
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On