From 1e3d6bfbe47703655761f6365efe2c25cd9b861c Mon Sep 17 00:00:00 2001 From: fengyang Date: Tue, 10 Sep 2024 11:44:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20to=5Fnumber=20=E6=96=B0?= =?UTF-8?q?=E8=AF=AD=E6=B3=95=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../docs-lite/en/docs/BriefTutorial/functions.md | 13 ++++++++++++- .../docs/BriefTutorial/type-conversion-functions.md | 13 ++++++++++++- .../docs/SQLReference/type-conversion-functions.md | 13 ++++++++++++- .../docs/BriefTutorial/\345\207\275\346\225\260.md" | 7 ++++++- ...\275\254\346\215\242\345\207\275\346\225\260.md" | 8 +++++++- content/en/docs/BriefTutorial/functions.md | 7 ++++++- .../docs/BriefTutorial/\345\207\275\346\225\260.md" | 10 ++++++++-- ...\275\254\346\215\242\345\207\275\346\225\260.md" | 8 +++++++- 8 files changed, 70 insertions(+), 9 deletions(-) diff --git a/content/docs-lite/en/docs/BriefTutorial/functions.md b/content/docs-lite/en/docs/BriefTutorial/functions.md index 72f89e71e..1064c490a 100644 --- a/content/docs-lite/en/docs/BriefTutorial/functions.md +++ b/content/docs-lite/en/docs/BriefTutorial/functions.md @@ -1099,10 +1099,21 @@ The common functions of openGauss are as follows: ``` -- to\_number\(text, text\) +- to\_number \( expr \[ DEFAULT return_value ON CONVERSION ERROR \] \[, fmt\]\) Description: Converts the values of the string type into the numbers in the specified format. + expr can be any expression that evaluates to a character string of type CHAR, VARCHAR2, NCHAR, or NVARCHAR2, a numeric value of type NUMBER, BINARY_FLOAT, + or BINARY_DOUBLE, or null. + 1. If expr is NUMBER, then the function returns expr. + 2. If expr evaluates to null, then the function returns null. + 3. Otherwise, the function converts expr to a NUMBER value. + + DEFAULT return_value ON CONVERSION ERROR is optional. Allows you to specify the value to be returned when a conversion error occurs. + Return_value can be an expression or a binding variable, and must be evaluated as a character string of type CHAR、VARCHAR2、NCHAR or NVARCHAR2, a numeric value of type NUMBER, BINARY_FLOAT or BINARY_DOUBLE, or null. + + fmt is optional. Format string. + Return type: numeric Example: diff --git a/content/docs-lite/en/docs/BriefTutorial/type-conversion-functions.md b/content/docs-lite/en/docs/BriefTutorial/type-conversion-functions.md index b0bfb3b27..d9c068899 100644 --- a/content/docs-lite/en/docs/BriefTutorial/type-conversion-functions.md +++ b/content/docs-lite/en/docs/BriefTutorial/type-conversion-functions.md @@ -380,10 +380,21 @@ (1 row) ``` -- to\_number \( expr \[, fmt\]\) +- to\_number \( expr \[ DEFAULT return_value ON CONVERSION ERROR \] \[, fmt\]\) Description: Converts **expr** into a value of the NUMBER type according to the specified format. + expr can be any expression that evaluates to a character string of type CHAR, VARCHAR2, NCHAR, or NVARCHAR2, a numeric value of type NUMBER, BINARY_FLOAT, + or BINARY_DOUBLE, or null. + 1. If expr is NUMBER, then the function returns expr. + 2. If expr evaluates to null, then the function returns null. + 3. Otherwise, the function converts expr to a NUMBER value. + + DEFAULT return_value ON CONVERSION ERROR is optional. Allows you to specify the value to be returned when a conversion error occurs. + Return_value can be an expression or a binding variable, and must be evaluated as a character string of type CHAR、VARCHAR2、NCHAR or NVARCHAR2, a numeric value of type NUMBER, BINARY_FLOAT or BINARY_DOUBLE, or null. + + fmt is optional. Format string. + For details about the type conversion formats, see [Table 1](#en-us_topic_0283137417_en-us_topic_0237121973_en-us_topic_0059778246_t3987a5bb00154b0f9e55863b4ababd3d). If a hexadecimal string is converted into a decimal number, the hexadecimal string can include a maximum of 16 bytes if it is to be converted into a sign-free number. diff --git a/content/docs-lite/en/docs/SQLReference/type-conversion-functions.md b/content/docs-lite/en/docs/SQLReference/type-conversion-functions.md index 32240d591..c8c9a9659 100644 --- a/content/docs-lite/en/docs/SQLReference/type-conversion-functions.md +++ b/content/docs-lite/en/docs/SQLReference/type-conversion-functions.md @@ -397,10 +397,21 @@ (1 row) ``` -- to\_number \( expr \[, fmt\]\) +- to\_number \( expr \[ DEFAULT return_value ON CONVERSION ERROR \] \[, fmt\]\) Description: Converts **expr** into a value of the NUMBER type according to the specified format. + expr can be any expression that evaluates to a character string of type CHAR, VARCHAR2, NCHAR, or NVARCHAR2, a numeric value of type NUMBER, BINARY_FLOAT, + or BINARY_DOUBLE, or null. + 1. If expr is NUMBER, then the function returns expr. + 2. If expr evaluates to null, then the function returns null. + 3. Otherwise, the function converts expr to a NUMBER value. + + DEFAULT return_value ON CONVERSION ERROR is optional. Allows you to specify the value to be returned when a conversion error occurs. + Return_value can be an expression or a binding variable, and must be evaluated as a character string of type CHAR、VARCHAR2、NCHAR or NVARCHAR2, a numeric value of type NUMBER, BINARY_FLOAT or BINARY_DOUBLE, or null. + + fmt is optional. Format string. + For details about the type conversion formats, see [Table 1](#en-us_topic_0283137417_en-us_topic_0237121973_en-us_topic_0059778246_t3987a5bb00154b0f9e55863b4ababd3d). If a hexadecimal string is converted into a decimal number, the hexadecimal string can include a maximum of 16 bytes if it is to be converted into a sign-free number. diff --git "a/content/docs-lite/zh/docs/BriefTutorial/\345\207\275\346\225\260.md" "b/content/docs-lite/zh/docs/BriefTutorial/\345\207\275\346\225\260.md" index a23e9c220..ad2530d04 100644 --- "a/content/docs-lite/zh/docs/BriefTutorial/\345\207\275\346\225\260.md" +++ "b/content/docs-lite/zh/docs/BriefTutorial/\345\207\275\346\225\260.md" @@ -1099,10 +1099,15 @@ openGauss常用的函数如下: ``` -- to\_number\(text, text\) +- to\_number \( text \[ DEFAULT return_value ON CONVERSION ERROR \] \[, fmt\]\) 描述:将字符串类型的值转换为指定格式的数字。 + DEFAULT return_value ON CONVERSION ERROR 可选的。允许指定在转换发生错误时返回的值。 + return_value 可以是表达式或绑定变量,并且必须计算为 CHAR、VARCHAR2、NCHAR 或 NVARCHAR2 类型的字符字符串、NUMBER、BINARY_FLOAT 或 BINARY_DOUBLE 类型的数值或 null。 + + fmt 可选的。格式化字符串。 + 返回值类型:numeric 示例: diff --git "a/content/docs-lite/zh/docs/SQLReference/\347\261\273\345\236\213\350\275\254\346\215\242\345\207\275\346\225\260.md" "b/content/docs-lite/zh/docs/SQLReference/\347\261\273\345\236\213\350\275\254\346\215\242\345\207\275\346\225\260.md" index 80905157d..96b578d4d 100644 --- "a/content/docs-lite/zh/docs/SQLReference/\347\261\273\345\236\213\350\275\254\346\215\242\345\207\275\346\225\260.md" +++ "b/content/docs-lite/zh/docs/SQLReference/\347\261\273\345\236\213\350\275\254\346\215\242\345\207\275\346\225\260.md" @@ -397,10 +397,16 @@ (1 row) ``` -- to\_number \( expr \[, fmt\]\) +- to\_number \( expr \[ DEFAULT return_value ON CONVERSION ERROR \] \[, fmt\]\) 描述:将expr按指定格式转换为一个NUMBER类型的值。 + 1. expr 输入为 CHAR、VARCHAR2、NCHAR 或 NVARCHAR2 类型的字符字符串、NUMBER、 BINARY_FLOAT 或 BINARY_DOUBLE 类型的数值,或 null。 + + 2. DEFAULT return_value ON CONVERSION ERROR 可选的。允许指定在转换发生错误时返回的值。 + * return_value 可以是表达式或绑定变量,并且必须计算为 CHAR、VARCHAR2、NCHAR 或 NVARCHAR2 类型的字符字符串、NUMBER、BINARY_FLOAT 或 BINARY_DOUBLE 类型的数值或 null。 + 3. fmt 可选的。格式化字符串。 + 类型转换格式请参考[表1](#zh-cn_topic_0283137417_zh-cn_topic_0237121973_zh-cn_topic_0059778246_t3987a5bb00154b0f9e55863b4ababd3d)。 转换十六进制字符串为十进制数字时,最多支持16个字节的十六进制字符串转换为无符号数。 diff --git a/content/en/docs/BriefTutorial/functions.md b/content/en/docs/BriefTutorial/functions.md index ced9f5622..a3bcec813 100644 --- a/content/en/docs/BriefTutorial/functions.md +++ b/content/en/docs/BriefTutorial/functions.md @@ -1099,10 +1099,15 @@ The common functions of openGauss are as follows: ``` -- to\_number\(text, text\) +- to\_number \( text \[ DEFAULT return_value ON CONVERSION ERROR \] \[, fmt\]\) Description: Converts the values of the string type into the numbers in the specified format. + DEFAULT return_value ON CONVERSION ERROR is optional. Allows you to specify the value to be returned when a conversion error occurs. + Return_value can be an expression or a binding variable, and must be evaluated as a character string of type CHAR、VARCHAR2、NCHAR or NVARCHAR2, a numeric value of type NUMBER, BINARY_FLOAT or BINARY_DOUBLE, or null. + + fmt is optional. Format string. + Return type: numeric Example: diff --git "a/content/zh/docs/BriefTutorial/\345\207\275\346\225\260.md" "b/content/zh/docs/BriefTutorial/\345\207\275\346\225\260.md" index ebc297f8b..3e1fa87d6 100644 --- "a/content/zh/docs/BriefTutorial/\345\207\275\346\225\260.md" +++ "b/content/zh/docs/BriefTutorial/\345\207\275\346\225\260.md" @@ -1099,9 +1099,15 @@ openGauss常用的函数如下: ``` -- to\_number\(text, text\) +- to\_number \( text \[ DEFAULT return_value ON CONVERSION ERROR \] \[, text\]\) - 描述:将字符串类型的值转换为指定格式的数字。 + 描述:将expr按指定格式转换为一个NUMBER类型的值。 + + 1. expr 输入为 CHAR、VARCHAR2、NCHAR 或 NVARCHAR2 类型的字符字符串、NUMBER、 BINARY_FLOAT 或 BINARY_DOUBLE 类型的数值,或 null。 + + 2. DEFAULT return_value ON CONVERSION ERROR 可选的。允许指定在转换发生错误时返回的值。 + * return_value 可以是表达式或绑定变量,并且必须计算为 CHAR、VARCHAR2、NCHAR 或 NVARCHAR2 类型的字符字符串、NUMBER、BINARY_FLOAT 或 BINARY_DOUBLE 类型的数值或 null。 + 3. fmt 可选的。格式化字符串。 返回值类型:numeric diff --git "a/content/zh/docs/SQLReference/\347\261\273\345\236\213\350\275\254\346\215\242\345\207\275\346\225\260.md" "b/content/zh/docs/SQLReference/\347\261\273\345\236\213\350\275\254\346\215\242\345\207\275\346\225\260.md" index 7d6572853..63aaf311e 100644 --- "a/content/zh/docs/SQLReference/\347\261\273\345\236\213\350\275\254\346\215\242\345\207\275\346\225\260.md" +++ "b/content/zh/docs/SQLReference/\347\261\273\345\236\213\350\275\254\346\215\242\345\207\275\346\225\260.md" @@ -398,10 +398,16 @@ (1 row) ``` -- to\_number \( expr \[, fmt\]\) +- to\_number \( expr \[ DEFAULT return_value ON CONVERSION ERROR \] \[, fmt\]\) 描述:将expr按指定格式转换为一个NUMBER类型的值。 + 1. expr 输入为 CHAR、VARCHAR2、NCHAR 或 NVARCHAR2 类型的字符字符串、NUMBER、 BINARY_FLOAT 或 BINARY_DOUBLE 类型的数值,或 null。 + + 2. DEFAULT return_value ON CONVERSION ERROR 可选的。允许指定在转换发生错误时返回的值。 + * return_value 可以是表达式或绑定变量,并且必须计算为 CHAR、VARCHAR2、NCHAR 或 NVARCHAR2 类型的字符字符串、NUMBER、BINARY_FLOAT 或 BINARY_DOUBLE 类型的数值或 null。 + 3. fmt 可选的。格式化字符串。 + 类型转换格式请参考[表1](#zh-cn_topic_0283137417_zh-cn_topic_0237121973_zh-cn_topic_0059778246_t3987a5bb00154b0f9e55863b4ababd3d)。 转换十六进制字符串为十进制数字时,最多支持16个字节的十六进制字符串转换为无符号数。 -- Gitee