IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

NOT IN clause in COBOL pgm


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mramvivek

New User


Joined: 20 Aug 2020
Posts: 1
Location: United States

PostPosted: Thu Aug 20, 2020 4:48 am
Reply with quote

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
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1049
Location: Richmond, Virginia

PostPosted: Thu Aug 20, 2020 6:36 am
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3076
Location: NYC,USA

PostPosted: Thu Aug 20, 2020 11:13 am
Reply with quote

Easy and optimum way is to put them in a GTT and do a inner join.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1314
Location: Vilnius, Lithuania

PostPosted: Thu Aug 20, 2020 12:02 pm
Reply with quote

Why didn't you try it in Spufi???
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2454
Location: Hampshire, UK

PostPosted: Thu Aug 20, 2020 2:06 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2135
Location: USA

PostPosted: Thu Aug 20, 2020 7:34 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3076
Location: NYC,USA

PostPosted: Tue Aug 25, 2020 8:27 pm
Reply with quote

You can always put them in a separate OR three times. Host variable will not work.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2454
Location: Hampshire, UK

PostPosted: Wed Aug 26, 2020 4:44 am
Reply with quote

Or he could simply remove the extra comma (after field2) and that would make the query conform to the syntax rules.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3076
Location: NYC,USA

PostPosted: Wed Aug 26, 2020 8:21 am
Reply with quote

Right, that's one of the error to fix before fixing the Where.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL sorting, with input GDG base COBOL Programming 7
No new posts Need help with ADABAS query (COBOL-AD... All Other Mainframe Topics 0
No new posts Replacing FILLER with FILLER<SeqNu... DFSORT/ICETOOL 2
No new posts Compile Sp Cobol base COBOL Programming 1
No new posts SQLCODE=-311 in Cobol SP-DB2. COBOL Programming 2
Search our Forums:

Back to Top