Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 125 additions & 2 deletions CN/modules/ROOT/pages/7.8.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
|interval day to second
|raw
|long
|blob
|clob
|nclob
|long_raw
|====

== 内置函数类型
Expand All @@ -47,7 +51,6 @@
|rtrim
|length
|lengthb
|rawtohex
|replace
|regexp_replace
|regexp_substr
Expand Down Expand Up @@ -75,6 +78,12 @@
|compose
|decompose
|sys_context
|bitand
|lpad
|rpad
|regexp_count
|to_clob
|to_blob
|====

== 内置函数说明
Expand Down Expand Up @@ -1150,4 +1159,118 @@ ivorysql=# select sys_context('USERENV','DB_NAME');
ivorysql
(1 row)

```
```

=== `BITAND` 函数
功能:对两个数值按二进制位执行逻辑与(AND)运算,返回运算结果。
语法:
```
bitand(number, number)
bitand(text, text)
```
参数说明:
- 第一个参数、第二个参数:参与按位与运算的两个数值;以字符串形式传入时会先转换为 `number` 再参与运算。
返回值:`number`,即按位与的运算结果。
示例:
```
select bitand(6, 3) from dual;
bitand
--------
2
(1 row)
```

=== `LPAD` 函数
功能:在字符串左侧填充指定字符,直到字符串达到目标长度。
语法:
```
lpad(varchar2, number [, varchar2])
```
参数说明:
- 第一个参数:待填充的字符串。
- 第二个参数:返回字符串的目标长度。
- 第三个参数:填充字符,缺省为空格。
返回值:`varchar2`。
示例:
```
select lpad('abc', 6, '*') from dual;
lpad
--------
***abc
(1 row)
```

=== `RPAD` 函数
功能:在字符串右侧填充指定字符,直到字符串达到目标长度。
语法:
```
rpad(varchar2, number [, varchar2])
```
参数说明:
- 第一个参数:待填充的字符串。
- 第二个参数:返回字符串的目标长度。
- 第三个参数:填充字符,缺省为空格。
返回值:`varchar2`。
示例:
```
select rpad('abc', 6, '*') from dual;
rpad
--------
abc***
(1 row)
```

=== `REGEXP_COUNT` 函数
功能:统计正则表达式在字符串中匹配的次数。
语法:
```
regexp_count(varchar2, varchar2 [, number [, varchar2]])
```
参数说明:
- 第一个参数:待匹配的字符串。
- 第二个参数:正则表达式。
- 第三个参数:开始搜索的位置,缺省为 1。
- 第四个参数:匹配模式,缺省为 `'g'`。
返回值:`int`,即匹配次数。
示例:
```
select regexp_count('abcabc', 'a') from dual;
regexp_count
--------------
2
(1 row)
```

=== `TO_CLOB` 函数
功能:将 `varchar2` 转换为 Oracle 兼容的 `clob` 数据类型。
语法:
```
to_clob(varchar2)
```
返回值:`clob`。
说明:`clob` 是 `sys` 模式下的域(domain)类型,底层数据类型为 `text`,因此可以直接参与字符串相关的运算与比较。
示例:
```
select to_clob('IvorySQL') from dual;
to_clob
----------
IvorySQL
(1 row)
```

=== `TO_BLOB` 函数
功能:将 `varchar2` 转换为 Oracle 兼容的 `blob` 数据类型。
语法:
```
to_blob(varchar2)
```
返回值:`blob`。
说明:`blob` 是 `sys` 模式下的域(domain)类型,底层数据类型为 `bytea`。
示例:
```
select to_blob('IvorySQL') from dual;
to_blob
--------------------
I766f727953514c
(1 row)
```
125 changes: 124 additions & 1 deletion EN/modules/ROOT/pages/7.8.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
|interval day to second
|raw
|long
|blob
|clob
|nclob
|long_raw
|====

== Built-in functions
Expand All @@ -47,7 +51,6 @@
|rtrim
|length
|lengthb
|rawtohex
|replace
|regexp_replace
|regexp_substr
Expand Down Expand Up @@ -75,6 +78,12 @@
|compose
|decompose
|sys_context
|bitand
|lpad
|rpad
|regexp_count
|to_clob
|to_blob
|====

== Built-in function descriptions
Expand Down Expand Up @@ -1149,3 +1158,117 @@ ivorysql=# select sys_context('USERENV','DB_NAME');
(1 row)

```

=== `BITAND` function
function: Returns the bitwise AND of two numbers.
Syntax:
```
bitand(number, number)
bitand(text, text)
```
Parameters:
- First parameter, second parameter: the two numbers to be combined by the bitwise AND operator; values passed as strings are converted to `number` first.
Returns: `number`, the result of the bitwise AND.
Example:
```
select bitand(6, 3) from dual;
bitand
--------
2
(1 row)
```

=== `LPAD` function
function: Pads the left side of a string with the given characters until the string reaches the requested length.
Syntax:
```
lpad(varchar2, number [, varchar2])
```
Parameters:
- First parameter: the string to be padded.
- Second parameter: the target length of the returned string.
- Third parameter: the padding characters, a space by default.
Returns: `varchar2`.
Example:
```
select lpad('abc', 6, '*') from dual;
lpad
--------
***abc
(1 row)
```

=== `RPAD` function
function: Pads the right side of a string with the given characters until the string reaches the requested length.
Syntax:
```
rpad(varchar2, number [, varchar2])
```
Parameters:
- First parameter: the string to be padded.
- Second parameter: the target length of the returned string.
- Third parameter: the padding characters, a space by default.
Returns: `varchar2`.
Example:
```
select rpad('abc', 6, '*') from dual;
rpad
--------
abc***
(1 row)
```

=== `REGEXP_COUNT` function
function: Counts how many times a regular expression matches in a string.
Syntax:
```
regexp_count(varchar2, varchar2 [, number [, varchar2]])
```
Parameters:
- First parameter: the string to be searched.
- Second parameter: the regular expression.
- Third parameter: the position where the search starts, 1 by default.
- Fourth parameter: the match parameter, `'g'` by default.
Returns: `int`, the number of matches.
Example:
```
select regexp_count('abcabc', 'a') from dual;
regexp_count
--------------
2
(1 row)
```

=== `TO_CLOB` function
function: Converts a `varchar2` value to the Oracle-compatible `clob` data type.
Syntax:
```
to_clob(varchar2)
```
Returns: `clob`.
Note: `clob` is a domain type in the `sys` schema whose base type is `text`, so the result can be used directly in string operations and comparisons.
Example:
```
select to_clob('IvorySQL') from dual;
to_clob
----------
IvorySQL
(1 row)
```

=== `TO_BLOB` function
function: Converts a `varchar2` value to the Oracle-compatible `blob` data type.
Syntax:
```
to_blob(varchar2)
```
Returns: `blob`.
Note: `blob` is a domain type in the `sys` schema whose base type is `bytea`.
Example:
```
select to_blob('IvorySQL') from dual;
to_blob
--------------------
I766f727953514c
(1 row)
```
Loading