Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Using INSPECT logic in COBOL using DB2

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
ajeshrn

New User


Joined: 25 Mar 2009
Posts: 78
Location: India

PostPosted: Tue Dec 06, 2011 7:17 pm    Post subject: Using INSPECT logic in COBOL using DB2
Reply with quote

Hi,

We have a scenario where we need to check the value of a column in db2 table and replace the first occurence of the space between words with a comma(,). Can someone suggest on how to achieve this. We are planning to use this query for a one time update on the table.

For example,
Current data in table
Test Name
Test


It should be replaced as below:
Test,Name
Test,
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Tue Dec 06, 2011 7:33 pm    Post subject: Reply to: Using INSPECT logic in COBOL using DB2
Reply with quote

INSPECT nice-descriptive-data-name REPLACING FIRST SPACE BY COMMA.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Tue Dec 06, 2011 7:56 pm    Post subject: Reply to: Using INSPECT logic in COBOL using DB2
Reply with quote

Ahh...

You mean you want to have some SQL which behaves in the same way as the above?
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Tue Dec 06, 2011 8:46 pm    Post subject:
Reply with quote

Code:
update tab1
set col1 =
case when (posstr(strip(col1),' ') > 0 ) then
     substr(col1,1,posstr(remarks,' ') - 1) || ',' ||
     substr(col1,posstr(remarks,' ') + 1)
else col1
end
Back to top
View user's profile Send private message
ajeshrn

New User


Joined: 25 Mar 2009
Posts: 78
Location: India

PostPosted: Thu Dec 08, 2011 4:42 pm    Post subject: Thanks
Reply with quote

Thanks a lot...It works and we were able to successfully update the table value with , for the first occurance of space... icon_smile.gif
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 -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm

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