Variable IN clause



IBM's flagship relational database management system

Variable IN clause

Postby ravi11081992 » Tue Dec 24, 2019 10:00 am

Hi,

I got a requirement to use IN clause with different host variable values like below

If condition = true
     Move "'T', 'V', 'W'" to :ws-variable
Else
     Move "'A', 'C'" to :ws-variable
End-if


I tried the below DB2 query but it's not accepting the syntax

Select employee_id into
           :Ws-employee-id
From employee
Where
Employee_variable in :ws-variable
 

I am getting error ws-variable cannot be used like this

As the number of values in 'IN' clause is changing, we cannot hard code the value in the host-variable

Can you please help

Thanks
ravi11081992
 
Posts: 18
Joined: Mon Apr 30, 2018 5:47 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Variable IN clause

 

Re: Variable IN clause

Postby NicC » Tue Dec 24, 2019 2:50 pm

Please use the code tags to pesent yur code.

What is the EXACT message that you are getting, including the message ID. (And use the code tags to present that as well.)
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2953
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 134 times

Re: Variable IN clause

Postby sergeyken » Thu Dec 26, 2019 8:22 pm

ravi11081992 wrote:I got a requirement to use IN clause with different host variable values like below

If condition = true
     Move "'T', 'V', 'W'" to :ws-variable
Else
     Move "'A', 'C'" to :ws-variable
End-if


I tried the below DB2 query but it's not accepting the syntax

Select employee_id into
           :Ws-employee-id
From employee
Where
Employee_variable in :ws-variable
 

The manager who gave a requirement like this (if it is really what he required?) - he must be fired from his position in the next minute, or two.
sergeyken
 
Posts: 37
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 2 times
Been thanked: 6 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post