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!

Format model oddity; G and V combined

ArildJun 19 2012 — edited Jun 19 2012
Hi,

can I have your opinion on this..

Some background if you're not familiar with the 'V' in format models:
select to_char(100, '999999999V9') newnum from dual;  --- 100 * 10^1 =   1 000

select to_char(100, '99999999V99') newnum from dual;  --- 100 * 10^2 =  10 000

select to_char(100, '9999999V999') newnum from dual;  --- 100 * 10^3 = 100 000
In short; it multiplies with 10 ^ (number of 9's after the V) , and rounds as needed. Simple, and sometimes useful.

Now, I found that I could format the result with group separator in one go, so I had this
select to_char(1000000, '999G999G999') newnum from dual;  --- 1 mill -> 1,000,000
reduced to 100K , and added a V9 to the end of the format model:
select to_char(100000, '999G999G999V9') newnum from dual;  --- 1 mill -> 1,000,000 ??
but I got this:


100,0000

1 row selected.


Now, wouldn't you agree it's a bit weird? I would have expected the V to operate before the G's , to return 1,000,000 .

How about you? There are others that could be useful which doesn't work, for example
select to_char( 1000, '999G999.99V9') newnum from dual; 

ORA-01481: invalid number format model
when I'd like to see '10 000.00'. Feels a little buggy that it works at all, the above?

I have
select * from nls_database_parameters;

PARAMETER                      VALUE                                   
------------------------------ ----------------------------------------
NLS_LANGUAGE                   AMERICAN                                
NLS_TERRITORY                  AMERICA                                 
NLS_CURRENCY                   $                                       
NLS_ISO_CURRENCY               AMERICA                                 
NLS_NUMERIC_CHARACTERS         .,                                      
NLS_CHARACTERSET               WE8MSWIN1252                            
NLS_CALENDAR                   GREGORIAN                               
NLS_DATE_FORMAT                DD-MON-RR                               
NLS_DATE_LANGUAGE              AMERICAN                                
NLS_SORT                       BINARY                                  
NLS_TIME_FORMAT                HH.MI.SSXFF AM                          
NLS_TIMESTAMP_FORMAT           DD-MON-RR HH.MI.SSXFF AM                
NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZR                      
NLS_TIMESTAMP_TZ_FORMAT        DD-MON-RR HH.MI.SSXFF AM TZR            
NLS_DUAL_CURRENCY              $                                       
NLS_COMP                       BINARY                                  
NLS_LENGTH_SEMANTICS           BYTE                                    
NLS_NCHAR_CONV_EXCP            FALSE                                   
NLS_NCHAR_CHARACTERSET         AL16UTF16                               
NLS_RDBMS_VERSION              11.2.0.1.0                              

20 rows selected.
Well, just thought I'd mention it :)

Rgds, A
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 17 2012
Added on Jun 19 2012
4 comments
916 views