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

Querry to fetch numbers without suppressing zeroes.


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

New User


Joined: 06 Feb 2010
Posts: 3
Location: Canada

PostPosted: Wed Jul 07, 2010 5:41 am
Reply with quote

I need to fetch a number from a table and it must come with padded zeroes.
e.g: the table has numeric(5) and value 123.
Then after fetch the query must retuen 00123 and not 123.

How do I do this?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jul 07, 2010 5:48 am
Reply with quote

imbedded sql (in a program)
or a spufi/qmf query?

apparently, the column datatype is char???????

if the column is numeric, then the value of the column will be right justified,
zero filled to the left - for the length of the column as defined by the column attributes.
Back to top
View user's profile Send private message
RonaldCDcosta

New User


Joined: 06 Feb 2010
Posts: 3
Location: Canada

PostPosted: Wed Jul 07, 2010 5:55 am
Reply with quote

This is a spufi query and the column is numeric.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jul 07, 2010 5:59 am
Reply with quote

you can use a scalar function like digits (cast)
Back to top
View user's profile Send private message
RonaldCDcosta

New User


Joined: 06 Feb 2010
Posts: 3
Location: Canada

PostPosted: Wed Jul 07, 2010 6:01 am
Reply with quote

can you please write a small query using this function? I am not sure of the syntax.
Back to top
View user's profile Send private message
keane

New User


Joined: 24 Jul 2006
Posts: 11

PostPosted: Wed Jul 07, 2010 7:37 am
Reply with quote

Check this it will work for you
SELECT DIGITS(COLUMN NAME) FROM TABLE
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Remove leading zeroes SYNCSORT 4
No new posts Fetch data from programs execute (dat... DB2 3
No new posts Code Multi Row fetch in PL1 program PL/I & Assembler 1
Search our Forums:

Back to Top