Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
pjnithin

Active User

Joined: 22 Dec 2005
Posts: 116

 Posted: Tue Jul 10, 2007 12:35 pm    Post subject: how to get only the number part and avoid the decimal part.. how to avoid the decimal part while selecting a field which is declared to have decimals in db2

sandeep1dimri

New User

Joined: 30 Oct 2006
Posts: 76

 Posted: Tue Jul 10, 2007 1:07 pm    Post subject: May be this will help SELECT SUBSTR(CHAR(ur-decimal-variable),1,10) From ur-table where conditions Note: I have consider the decimal variable Decimal(11,2). Sandeep
vijaysharma

New User

Joined: 04 Jul 2007
Posts: 3
Location: Bangalore

 Posted: Tue Jul 10, 2007 2:52 pm    Post subject: May be this will help Just adding to previous one........... SELECT SUBSTR(CHAR(table-variable),1,10) INTO : host-variable FROM ur-table WHERE conditions
Raphael Bacay

New User

Joined: 04 May 2007
Posts: 58
Location: Manila, Philippines

 Posted: Fri Aug 03, 2007 10:03 am    Post subject: Hi! I just found that in SQL you can do this so maybe it is applicable to your problem. SELECT FLOOR(column name) INTO :host variable FROM table WHERE ... *FLOOR function will return the non-decimal part of a digit. Regards.
Alan Voss

New User

Joined: 29 Nov 2006
Posts: 32
Location: Jacksonville, FL

 Posted: Fri Aug 03, 2007 7:06 pm    Post subject: Be sure that floor is what you want, rather than integer: select A.I, integer(A.i) as I_INT, floor(A.I) as I_FLOORED from DECIMALS as A order by A.i; completed successfully. I I_INT I_FLOORED ------ ----------- --------- -5.00 -5 -5 -4.75 -4 -5 -4.50 -4 -5 -4.25 -4 -5 -4.00 -4 -4 -3.75 -3 -4 -3.50 -3 -4 -3.25 -3 -4 -3.00 -3 -3 -2.75 -2 -3 -2.50 -2 -3 -2.25 -2 -3 -2.00 -2 -2 -1.75 -1 -2 -1.50 -1 -2 -1.25 -1 -2 -1.00 -1 -1 -0.75 0 -1 -0.50 0 -1 -0.25 0 -1 0.00 0 0 0.25 0 0 0.50 0 0 0.75 0 0 1.00 1 1 1.25 1 1 1.50 1 1 1.75 1 1 2.00 2 2 2.25 2 2 2.50 2 2 2.75 2 2 3.00 3 3 3.25 3 3 3.50 3 3 3.75 3 3 4.00 4 4 4.25 4 4 4.50 4 4 4.75 4 4 5.00 5 5 41 rows selected in 0.07 secs.
dick scherrer

Site Director

Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

 Posted: Fri Aug 03, 2007 7:33 pm    Post subject: Good catch
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics INVALID RECFM FOR DDNAME SYSLIN AND C... sandeep kumar302 All Other Mainframe Topics 7 Fri Apr 27, 2018 6:07 pm Linkage editor is part of COBOL, z/OS... ankit.jain COBOL Programming 5 Fri Apr 20, 2018 4:17 pm Repeat Sequence Number Until change i... rahulabvp DFSORT/ICETOOL 6 Thu Mar 29, 2018 12:51 pm How to group and sum the decimal value sakrat DFSORT/ICETOOL 2 Tue Mar 06, 2018 9:13 pm add sequence number for duplicate rec... SRUTHI DRAVIDAMANI COBOL Programming 11 Thu Feb 22, 2018 5:37 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us