Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Querry to fetch numbers without suppressing zeroes.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Querry to fetch numbers without suppressing zeroes.
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: 6968
Location: porcelain throne

PostPosted: Wed Jul 07, 2010 5:48 am    Post subject:
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    Post subject:
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: 6968
Location: porcelain throne

PostPosted: Wed Jul 07, 2010 5:59 am    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts Format record to remove Leading zeroes Learncoholic DFSORT/ICETOOL 14 Wed Apr 05, 2017 2:43 pm
No new posts Incorrect output when trying to add n... monica1 PL/I & Assembler 10 Fri Jan 13, 2017 5:02 pm
No new posts Row-Numbers of distinct rows? Auryn DB2 1 Thu Oct 20, 2016 4:38 pm
No new posts Multi row fetch - "for read only... Nileshkul DB2 3 Sun Aug 14, 2016 12:52 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us