Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

number conversions to string issue

user4421692Mar 10 2016 — edited Mar 10 2016

Hi all,

I have the following table:

desc INC_PER_YEAR

Name                    Null   Type       

----------------------- -------- ------------

COD_ORG          NOT NULL CHAR(12)    

YEAR                 NOT NULL CHAR(4)        

VAL_INC            NOT NULL NUMBER   

The value of val_inc is a decimal withe 1 digiti on left of decimal separator and a variable number of digit on the rigth of decimal point.

ES:

0.1234567

1.234

Using a cursor like:

SELECT *

FROM    INC_PER_YEAR

WHERE YEAR = parm_input

I need to write on a file ( using UTL_FILE procedure ) the following output:

COD_ORG|YEAR|VAL_INC


I use the following concat:


cur.COD_ORG||'|'||cur.YEAR||'|'||cur.VAL_INC


But VAL_INC look like


0.1234567 -> .1234567

1.234       -> 1.234


I already check the number format parameter of TO_CHAR, but how can I set the correct number of significant digit?


If I use TO_CHAR(0.1234567,'9.99999')  I have 0.1234567 on file but when I use TO_CHAR(0.1234,'9.99999') I have 0.1234000.


Thanks for all and best regards




Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 7 2016
Added on Mar 10 2016
13 comments
1,332 views