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

Want to change length from 3 fields to 4 fields using DB2


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

New User


Joined: 22 Sep 2006
Posts: 33

PostPosted: Wed Mar 07, 2007 4:52 pm
Reply with quote

Hi,

I have a field heving length of 3 characters, now i want to change this as 4 characters using DB2.

Example in table field1 is having value '384', now I want to change this as '0384' in table using DB2 ....

Can i use LIKE for this purpose....

Please help me in this regard.....
Back to top
View user's profile Send private message
vini_srcna

Active User


Joined: 26 May 2005
Posts: 178
Location: Copenhagen, Denmark

PostPosted: Wed Mar 07, 2007 5:37 pm
Reply with quote

Are you taking about the data in the field1..?

What is the datatype of field1. Is that CHAR(03)...? Do you need to change that to CHAR(04) ...?

If you want to change it from CHAR(03) to CHAR(04) then get in touch with DBA and make sure all the application programs accessing that table/column are changed accordingly.The DDL of that table needs to be altered. If you are talking about just the data then it could be done with simple SQL query.
Back to top
View user's profile Send private message
santhunaveen

New User


Joined: 22 Sep 2006
Posts: 33

PostPosted: Wed Mar 07, 2007 5:53 pm
Reply with quote

Hi,

I want to change data only.......thru sql query how can we do this......can u give me some suedo code for this..............
Back to top
View user's profile Send private message
vini_srcna

Active User


Joined: 26 May 2005
Posts: 178
Location: Copenhagen, Denmark

PostPosted: Wed Mar 07, 2007 7:30 pm
Reply with quote

UPDATE tablename SET colname = '0'||colname ;
Back to top
View user's profile Send private message
vini_srcna

Active User


Joined: 26 May 2005
Posts: 178
Location: Copenhagen, Denmark

PostPosted: Wed Mar 07, 2007 7:32 pm
Reply with quote

That will update all the records in the table. Make sure you are correct before you execute the query.
Back to top
View user's profile Send private message
santhunaveen

New User


Joined: 22 Sep 2006
Posts: 33

PostPosted: Thu Mar 08, 2007 6:00 pm
Reply with quote

Hi,

Thanks.....it's working fine.......
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 Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts VB to VB copy - Full length reached SYNCSORT 8
No new posts 3270 personal communications. Can't c... TSO/ISPF 2
Search our Forums:

Back to Top