Avatar of Mannsi
Mannsi

asked on 

Commas and Periods in Oracle

Hello experts,
I'm having some problems inserting numbers with commas (5,15) into my oracle db. I am located in Europe so this is standard. When I try to insert the number I get a 'invalid number' error.
I wan't both the input to use commas and I wan't the db to display commas as well. Can this be done ?

ps. I'm using visual basic if that changes anything.
Oracle Database

Avatar of undefined
Last Comment
Qlemo
Avatar of Mannsi
Mannsi

ASKER

Forgot to mention, the fields in the db have data type 'Number'
Avatar of Mannsi
Mannsi

ASKER

Forget the question, I'm an idiot.
ASKER CERTIFIED SOLUTION
Avatar of Shaju Kumbalath
Shaju Kumbalath
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Mannsi
Mannsi

ASKER

Thanks
Avatar of Mannsi
Mannsi

ASKER

Turns out I was too quick to assign points this time.
shajukg, my problem is that Oracle demands a period instead of a comma when deciding on decimal values. Can I somehow change the number (5,15) to (5.15) ?
please give me the output for following query
select * from NLS_SESSION_PARAMETERS
Avatar of Mannsi
Mannsi

ASKER

PARAMETER      VALUE
NLS_LANGUAGE      ICELANDIC
NLS_TERRITORY      ICELAND
NLS_CURRENCY      kr.
NLS_ISO_CURRENCY      ICELAND
NLS_NUMERIC_CHARACTERS      ,.
NLS_CALENDAR      GREGORIAN
NLS_DATE_FORMAT      DD.MM.RRRR
NLS_DATE_LANGUAGE      ICELANDIC
NLS_SORT      ICELANDIC
NLS_TIME_FORMAT      HH24:MI:SSXFF
NLS_TIMESTAMP_FORMAT      DD.MM.RRRR HH24:MI:SSXFF
NLS_TIME_TZ_FORMAT      HH24:MI:SSXFF TZR
NLS_TIMESTAMP_TZ_FORMAT      DD.MM.RRRR HH24:MI:SSXFF TZR
NLS_DUAL_CURRENCY      kr.
NLS_COMP      BINARY
NLS_LENGTH_SEMANTICS      BYTE
NLS_NCHAR_CONV_EXCP      FALSE
Avatar of Qlemo
Qlemo
Flag of Germany image

After
ALTER SESSION SET NLS_NUMERIC_CHARACTERS = ",.";
you can use
update tbl set numcol = to_number('1,1');

If you convert numbers to varchar you will get the comma on outputs.

Since the dot for numeric literals is part of SQL syntax, you can not use decimal comma directly.


select to_number('5,15','9999999d999') from dual;
there is no need to alter session as the parameter value is already
NLS_NUMERIC_CHARACTERS      ,.

i think u need to use the formating used in my above example
Avatar of Qlemo
Qlemo
Flag of Germany image

No need to give format mask for to_number;
no need to alter NLS_NUMERIC_CHARACTERS as it is set up already.
Oracle Database
Oracle Database

Oracle is an object-relational database management system. It supports a large number of languages and application development frameworks. Its primary languages are SQL, PL/SQL and Java, but it also includes support for C and C++. Oracle also has its own enterprise modules and application server software.

81K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo