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

DB2 Query to reformat the output


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts RC query -Time column CA Products 3
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top