Auto cast on macos

select '5.00' + 1 from dual;
this query run on datagrip window but error on datagrip (macos). I cant fix this

1
9 comments

Hi - The query runs just fine for me on MySQL.

What database & SQL dialect do you use? 

What is the error message?

1

Hi , database Oracle and SQL dialect <Oracle, Oracle SQL Plus>

Error msg : [42000][1722] ORA-01722: invalid number

1

What is the expected result of the query?

AFAIK, concatenation of strings and numbers is performed using the || operator or CONCAT() function. So executing select '5.00' || 1 from dual; should return 5.001

Executing select 5.00 || 1 from dual; will give you 51.

If you want to add one number to the other, you need to drop the single quotes: select 5.00 + 1 as col1 from dual; → returns 6.

0

yes, the problem is on Datagrip version window this query can run, but on mac version it can not run and i dont know why

0

Please collect IDE logs and upload them to https://uploads.jetbrains.com for analysis: 

  1. Help | Collect Logs and Diagnostic Data
  2. Help | Show SQL Log in…

Don't forget to provide the id of the upload here.

0

SQL log in :
-- 2024-01-12 07:37:06 [Burger] [PSP TEST] [console: console_1 [PSP TEST]] [session id: 1065477147] [statement id: 1619840272] 
select '5.00' + 1 from dual
-- ] --------------------------------------------------
-- 2024-01-12 07:37:06 [Burger] [PSP TEST] [console: console_1 [PSP TEST]] [session id: 1065477147] [statement id: 1619840272] error - [42000][1722] ORA-01722: invalid number
-- 2024-01-12 07:37:06 [Burger] [PSP TEST] [console: console_1 [PSP TEST]] [session id: 1065477147] [statement id: 1619840272] finished - execution time: 103 ms

0

Hello,

Do you use the same DB on Mac and Windows and driver versions? Could you please provide log from Windows machine where it works fine?

0

Yes, i use the same DB and driver versions in mac and window 
this is log in window version:

-- 2024-01-15 10:38:46 [Burger] [DB TEST] [console: console_1 [DB TEST]] [session id: 1039362261] [statement id: 1756569505] 
select '5.00' + 1 from DUAL
-- ] --------------------------------------------------
-- 2024-01-15 10:38:46 [Burger] [DB TEST] [console: console_1 [DB TEST]] [session id: 1039362261] [statement id: 1756569505] results received
-- 2024-01-15 10:38:46 [Burger] [DB TEST] [console: console_1 [DB TEST]] [session id: 1039362261] [statement id: 1756569505] finished - execution time: 40 ms, fetching time: 86 ms, total result sets count: 1
 

0

Seems you have different decimal separator on machines. You may run this query to check current settings:

"select value
from nls_session_parameters
where parameter = 'NLS_NUMERIC_CHARACTERS';"

To avoid such cases you may use “to_number” function:

“select to_number('5.00', '99999D99','NLS_NUMERIC_CHARACTERS=''.,''') + 1 from DUAL;”

or run this before request:

“alter session set NLS_NUMERIC_CHARACTERS = '.,';”

 

0

Please sign in to leave a comment.