IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How do i replace the 1st byte of a string


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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

Superior Member


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

PostPosted: Wed May 06, 2009 6:22 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Help with C character vs C string All Other Mainframe Topics 3
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
Search our Forums:

Back to Top