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
 
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 How to convert 2 bytes into single by... pkmurali DB2 0 Fri May 25, 2018 1:41 pm
No new posts Find & Replace string in CA-SORT mrgnndhmk CA Products 1 Fri Mar 30, 2018 12:58 am
No new posts Replace last name by first name anatol DFSORT/ICETOOL 10 Thu Mar 15, 2018 3:43 pm
No new posts help to replace columns by rows Vikas Maharnawar DFSORT/ICETOOL 8 Tue Mar 06, 2018 3:27 pm
No new posts How to replace the below query? pkmurali DB2 12 Tue Feb 27, 2018 9:51 pm

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