【问题标题】:Error trying to convert char to number尝试将字符转换为数字时出错
【发布时间】:2011-09-22 17:40:28
【问题描述】:

我有一个信息,我假设它是 char 类型,因为我有以下信息(dbms_output.put_line 是一个类似“print”的函数,返回值在 --> 之后):

dbms_output.put_line( table_record.column_1 ); --> 0.6
dbms_output.put_line( UPPER(table_record.column_1) ); --> 0.6
dbms_output.put_line( LOWER(table_record.column_1) ); --> 0.6

但我不希望那样。我想将此列转换为 FLOAT 类型。当我尝试时:

dbms_output.put_line( to_number(crate_record.column_1) );

我有 ORA-06502:PL/SQL:数字或值错误:字符到数字的转换错误。

为什么 to_number 不起作用?

【问题讨论】:

标签: oracle10g


【解决方案1】:

请尝试更改会话和格式掩码

alter session set NLS_NUMERIC_CHARACTERS=".,"

dbms_output.put_line( to_number(crate_record.column_1,999999999.99) );

如果您希望整个应用程序使用相同的小数和组分隔符,请更改 DB 中的 NLS_NUMERIC_CHARACTERS,下面的链接可能会有所帮助

https://forums.oracle.com/forums/thread.jspa?threadID=899739

【讨论】:

    猜你喜欢
    • 2017-01-29
    • 1970-01-01
    • 2017-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多