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 Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts 2 byte YEAR from Y'DATE2' field tecnokrat DFSORT/ICETOOL 2 Tue Feb 07, 2017 12:05 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm


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