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
 

 

DB2 Query to reformat the output

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
amitava
Warnings : 1

Active User


Joined: 30 Oct 2005
Posts: 186
Location: India

PostPosted: Thu Nov 30, 2006 5:05 pm    Post subject: DB2 Query to reformat the output
Reply with quote

Hi All,
I am having a DB2 table with one of field is of SMALLINT type (say FIELD1). But I want to use a query which will give the output with the following input-



I/P :-
Code:

FIELD1
=====
1
12
21




O/P :-
Code:

FIELD1
=====
001
012
021
[/code]
Back to top
View user's profile Send private message

MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Thu Nov 30, 2006 8:46 pm    Post subject: Re: DB2 Query to reformat the output
Reply with quote

Try column function DIGITS.

Code:

DIGITS                                                                     
                                                                           
+------------------------------------------------------------------------+ 
|                                                                        | 
| >>--DIGITS(numeric-expression)-------------------------------------->< | 
|                                                                        | 
+------------------------------------------------------------------------+ 
                                                                           
The schema is SYSIBM.                                                       
                                                                           
The DIGITS function returns a character string representation of the       
absolute value of a number.                                                 
                                                                           
The argument must be an expression that returns the value of one of the     
following built-in numeric data types: SMALLINT, INTEGER, or DECIMAL.       
                                                                           
If the argument can be null, the result can be null; if the argument is     
null, the result is the null value.                                         

The result of the function is a fixed-length character string representing 
the absolute value of the argument without regard to its scale. The result 
does not include a sign or a decimal point. Instead, it consists           
exclusively of digits, including, if necessary, leading zeros to fill out   
the string. The length of the string is:                                   
                                                                           
o   5 if the argument is a small integer                                   
o   10 if the argument is a large integer                                   
o   p if the argument is a decimal number with a precision of p             
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 find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am
No new posts Problem reading GTF trace output danik56 ABENDS & Debugging 7 Thu Mar 16, 2017 1:02 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts How to get current date -1 and curren... murali.andaluri DFSORT/ICETOOL 3 Wed Mar 08, 2017 2:09 pm


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