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

REPLACE/UPDATE a partial string in a column (VARCHAR type)


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mallikannasagaram

New User


Joined: 21 Feb 2006
Posts: 9
Location: india

PostPosted: Thu Aug 02, 2007 1:42 pm
Reply with quote

Hi,

I need to REPLACE/UPDATE a partial string 'PQ' to 'QC' in a column (VARCHAR type) using SQL query. Please find following example for better understanding.

Example:
COLUMN VALUE UPADATE STRING
1000ABPQ 1000ABQC
XCPQJK XCQCJK
PQ QC

Please tell me the best way to do this...

Thanks & Regards,
Mallik
Back to top
View user's profile Send private message
mallikannasagaram

New User


Joined: 21 Feb 2006
Posts: 9
Location: india

PostPosted: Thu Aug 02, 2007 1:45 pm
Reply with quote

Example:
COLUMN VALUE
1000ABPQ
XCPQJK
PQ

UPADATE STRING
1000ABQC
XCQCJK
QC
Back to top
View user's profile Send private message
Raphael Bacay

New User


Joined: 04 May 2007
Posts: 58
Location: Manila, Philippines

PostPosted: Fri Aug 03, 2007 9:30 am
Reply with quote

Hi!

I think you need to use COBOL with this.
You can SELECT all rows containing 'PQ' with a
COL = *PQ*.

Then you can Do a fetch of all rows containing columns
with PQ. Then you can do an INSPECT REPLACING ALL 'PQ' BY 'QC'.
Then you can UPDATE the replaced value into the table as you fetch
each row.

All in all you SELECT, FETCH, INSPECT, UPDATE each row that contains
the string 'PQ' to replace it with 'QC'.


Regards.
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 Replace each space in cobol string wi... COBOL Programming 2
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 Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts How to load to DB2 with column level ... DB2 6
Search our Forums:

Back to Top