Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts COBOL Programming Sandpit? jodrisco COBOL Programming 6 Wed Apr 12, 2017 3:47 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us