MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Pad Zeroes for a Numeric item in a Db2 table

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
nag77
Beginner


Joined: 03 Jan 2006
Posts: 11
Topics: 8

PostPosted: Sat Jan 28, 2006 5:12 am    Post subject: Pad Zeroes for a Numeric item in a Db2 table Reply with quote

Hi

I have one variable named as numeric-item with SIZE 10.
Some NIs are with size 5.

NI
-----
1243231231
1243231231
12432
12432

If the 6th-10th bytes are not available ,I have to insert zeros in the spaces, i mean the vales of NI should be like

NI
-----
1243231231
1243231231
1243200000
1243200000

How can i do this??

Thanks in Advance..

Regards
Nag.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Sat Jan 28, 2006 5:55 am    Post subject: Reply with quote

nag77,

Try this

Code:

SELECT REPLACE(your_Num_COL,' ','0')
  FROM TABLE
;


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nag77
Beginner


Joined: 03 Jan 2006
Posts: 11
Topics: 8

PostPosted: Sat Jan 28, 2006 6:05 am    Post subject: Reply with quote

Hi kolusu

I have other variables also in this table
ex: Fn pic x(10).
Ln Pic x(10).
NI pic x(10).

when this case i have to give the query as

SELECT REPLACE(25,30,' ','0')
FROM TABLE
;

is it right????

thanks
NAG
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Sat Jan 28, 2006 6:09 am    Post subject: Reply with quote

nag77,

where did you get the 25,30 from in your SELECT clause?

Your sql will be

Code:

SELECT REPLACE(FN,' ','0')
      ,REPLACE(LN,' ','0')
      ,REPLACE(NI,' ','0')
  FROM TABLE
;


Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group