Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 query to fetch record which has only ... maxsubrat DB2 12 Mon Dec 11, 2017 5:03 pm
No new posts How to query MAXGENS of an existing P... Chuchulo Hatyzak JCL & VSAM 4 Wed Nov 22, 2017 10:23 pm
No new posts Native SQL Query kishpra DB2 1 Wed Nov 22, 2017 8:38 pm
No new posts VBS and VB, COBOL syntax is the same ... natt.sut COBOL Programming 3 Sun Nov 12, 2017 6:36 am
No new posts Query on IEFBR14 with GDG Ashishpanpaliya JCL & VSAM 4 Tue Nov 07, 2017 8:34 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us