Portal | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
NOT IN clause in COBOL pgm

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: NOT IN clause in COBOL pgm
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: 1010
Location: Richmond, Virginia

PostPosted: Thu Aug 20, 2020 6:36 am    Post subject:
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: 2467
Location: NY,USA

PostPosted: Thu Aug 20, 2020 11:13 am    Post subject:
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: 1220
Location: Vilnius, Lithuania

PostPosted: Thu Aug 20, 2020 12:02 pm    Post subject:
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: 2407
Location: Hampshire, UK

PostPosted: Thu Aug 20, 2020 2:06 pm    Post subject: Reply to: NOT IN clause in COBOL pgm
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

Active Member


Joined: 29 Apr 2008
Posts: 825
Location: Maryland

PostPosted: Thu Aug 20, 2020 7:34 pm    Post subject:
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: 2467
Location: NY,USA

PostPosted: Tue Aug 25, 2020 8:27 pm    Post subject:
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: 2407
Location: Hampshire, UK

PostPosted: Wed Aug 26, 2020 4:44 am    Post subject: Reply to: NOT IN clause in COBOL pgm
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: 2467
Location: NY,USA

PostPosted: Wed Aug 26, 2020 8:21 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Missing Negative sign in COBOL jzhardy COBOL Programming 0 Sat Sep 26, 2020 11:32 am
No new posts COBOL reading from SYSIN jzhardy COBOL Programming 1 Mon Sep 21, 2020 2:37 pm
No new posts how to read accounting information in... jzhardy COBOL Programming 1 Mon Sep 21, 2020 9:57 am
No new posts Restart logic by using cursor name in... Twinkle22 Mainframe Interview Questions 1 Wed Jul 29, 2020 11:26 am
No new posts COBOL Developers Perspectives on Soft... achakarov COBOL Programming 4 Sat Jul 18, 2020 1:26 am

Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us