§ Oracle Compatibility - Function - NCHR()
§ 1. Syntax
NCHR(n)
1
§ 2. Definition and Usage
The NCHR() function converts a Unicode code point to the corresponding character. Its usage is similar to the CHR() function, except that a Unicode code point is used instead of an ASCII code.
The requirements for parameter n are as follows:
- The value of
nmust be non-negative; a negative value raises an error. ncan also be an integer or a floating-point number; floating-point numbers are automatically converted to integers (after taking the absolute value). For example, 97.3 is converted to 97, and 97.6 is also converted to 97.ncan also be a string, which must be convertible to a non-negative integer.
§ 3. Examples
greatsql> SET @n=97.184; SELECT @n, NCHR(@n), LENGTH(NCHR(@n)), LENGTHB(NCHR(@n)), ORD(NCHR(@n))\G
Query OK, 0 rows affected (0.00 sec)
*************************** 1. row ***************************
@n: 97.184
NCHR(@n): a
LENGTH(NCHR(@n)): 1
LENGTHB(NCHR(@n)): 1
ORD(NCHR(@n)): 97
greatsql> SET @n=97.684; SELECT @n, NCHR(@n), LENGTH(NCHR(@n)), LENGTHB(NCHR(@n)), ORD(NCHR(@n))\G
Query OK, 0 rows affected (0.00 sec)
*************************** 1. row ***************************
@n: 97.684
NCHR(@n): a
LENGTH(NCHR(@n)): 1
LENGTHB(NCHR(@n)): 1
ORD(NCHR(@n)): 97
greatsql> SET @n=-97.684; SELECT @n, NCHR(@n), LENGTH(NCHR(@n)), LENGTHB(NCHR(@n)), ORD(NCHR(@n))\G
Query OK, 0 rows affected (0.00 sec)
ERROR 1210 (HY000): Incorrect arguments to function nchr.
greatsql> SET @n='97.684'; SELECT @n, NCHR(@n), LENGTH(NCHR(@n)), LENGTHB(NCHR(@n)), ORD(NCHR(@n))\G
Query OK, 0 rows affected (0.00 sec)
*************************** 1. row ***************************
@n: 97.684
NCHR(@n): a
LENGTH(NCHR(@n)): 1
LENGTHB(NCHR(@n)): 1
ORD(NCHR(@n)): 97
1 row in set (0.00 sec)
greatsql> SET @n='97.184'; SELECT @n, NCHR(@n), LENGTH(NCHR(@n)), LENGTHB(NCHR(@n)), ORD(NCHR(@n))\G
Query OK, 0 rows affected (0.00 sec)
*************************** 1. row ***************************
@n: 97.184
NCHR(@n): a
LENGTH(NCHR(@n)): 1
LENGTHB(NCHR(@n)): 1
ORD(NCHR(@n)): 97
greatsql> SET @n='97.184a'; SELECT @n, NCHR(@n), LENGTH(NCHR(@n)), LENGTHB(NCHR(@n)), ORD(NCHR(@n))\G
Query OK, 0 rows affected (0.00 sec)
ERROR 1292 (22007): Truncated incorrect DOUBLE value: '97.184a'
greatsql> SET @n='97.184 '; SELECT @n, NCHR(@n), LENGTH(NCHR(@n)), LENGTHB(NCHR(@n)), ORD(NCHR(@n))\G
Query OK, 0 rows affected (0.00 sec)
*************************** 1. row ***************************
@n: 97.184
NCHR(@n): a
LENGTH(NCHR(@n)): 1
LENGTHB(NCHR(@n)): 1
ORD(NCHR(@n)): 97
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Scan the QR code to follow our WeChat official account
