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
 

 

How do i replace the 1st byte of a string

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

New User


Joined: 09 Apr 2008
Posts: 83
Location: Chennai

PostPosted: Wed May 06, 2009 1:04 pm    Post subject:
Reply with quote

How do i replace the 1st byte of a string 'A' of table XYZ with the 1st character of the string 'B' of table ABC within the same query?
For e.g. consider the following query:

Code:

--Employee_Prefix_ID is a 1-byte field
--Employee_ID is a 10-bye Alphanumeric Field.

SELECT XYZ.EMPLOYEE_ID
       ABC.EMPLOYEE_PREFIX_ID
FROM XYZ, ABC
WHERE XYZ.EMPLOYEE_ID = ABC.EMPLOYEE_ID


I want to replace the 1st byte of Employee_ID with the Employee_Prefix_ID.
Back to top
View user's profile Send private message

rahuindo

New User


Joined: 09 Apr 2008
Posts: 83
Location: Chennai

PostPosted: Wed May 06, 2009 3:22 pm    Post subject:
Reply with quote

Hi,
I got the answer. We can write the following query. icon_biggrin.gif
Code:

TRANSLATE(XYZ.EMPLOYEE_ID,ABC.EMPLOYEE_PREFIX_ID,       
        SUBSTR(XYZ.EMPLOYEE_ID,1,1)) AS "EMPLOYEE ID"
FROM XYZ, ABC
WHERE XYZ.EMPLOYEE_ID = ABC.EMPLOYEE_ID
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed May 06, 2009 6:22 pm    Post subject:
Reply with quote

Perfect . . . icon_smile.gif. Thanks for coming back and posting us with the solution.
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 Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
This topic is locked: you cannot edit posts or make replies. Sort card to replace text using cross... Susanta SYNCSORT 32 Tue Sep 13, 2016 4:17 pm
No new posts Replace function abdulrafi COBOL Programming 13 Mon Sep 12, 2016 10:12 am
No new posts Random Password (in string format) ge... ezhavendhan COBOL Programming 10 Mon Aug 29, 2016 3:18 pm


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