View previous topic :: View next topic
|
Author |
Message |
mramvivek
New User
Joined: 20 Aug 2020 Posts: 1 Location: United States
|
|
|
|
Hi ALl,
Can I use the NOT IN clause in cobol program as below ?
Using STRING verb, assign the value of 'a','b','c' to WS-NOT-IN and use the same in SQL
Code: |
EXECL SQL
SELECT FIELD1,FIELD2, FROM TABLENAME WHERE
FIELD3 NOT IN (:WS-NOT-IN)
END-EXEC |
Is this valid code ? I tried and it does not seems to work.
Coded for you - next time do it yourself |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1049 Location: Richmond, Virginia
|
|
|
|
Did you get a syntax error/warning or unexpected results?
If the former - what's the manual say?
If the latter, what did you expect and what did you get?
Finally - if you were a teacher or supervisor, aren't these questions you'd ask? |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
Easy and optimum way is to put them in a GTT and do a inner join. |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1314 Location: Vilnius, Lithuania
|
|
|
|
Why didn't you try it in Spufi??? |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Where are you having problems? The COBOL code? You didn't post any but you posted in the COBOL section of the forum. The SQL code? In which case why post in the COBOL section and not the DB2 section?
"It does not work" is a senseless statement without the information stating how it didn't work - messages, status codes. Provide the missing information and someone will be able to help.
p.s. You appear to have a ',' too many. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2135 Location: USA
|
|
|
|
prino wrote: |
Why didn't you try it in Spufi??? |
In SPUFI it would be not possible to specify the host variable, which is the only one under question in this example: how exactly the DB2 preprocessor does handle this EXEC SQL?
It’ very easy to run a tiny test; I don’t have access to the system right now. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
You can always put them in a separate OR three times. Host variable will not work. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Or he could simply remove the extra comma (after field2) and that would make the query conform to the syntax rules. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
Right, that's one of the error to fix before fixing the Where. |
|
Back to top |
|
|
|