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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
use ;
use crate::;
/**
Types that can be encoded using national character set.
*/
/**
Represents a value that will be encoded using national character set.
This type is used to indicate that a value bound to the parameter placeholder
should be encoded using national character set. This is normally not the case
as bound "[data is converted to the database character set before converting to
or from the national character set](https://docs.oracle.com/en/database/oracle/oracle-database/19/nlspg/programming-with-unicode.html#GUID-337FC5E5-9A3F-4E49-B6C5-A94D82607BB9)."
The use of this type is unnecessary if the database character set is Unicode
(AL32UTF8, UTF8, UTFE). In this case the conversion to the database character
set does not lose any data and thus the subsequent conversion to the national
character set preserves the original data.
However, if the database character set is not Unicode, then, depending on the
data, the conversion to the database character set might lose characters that
cannot be represented in the current database character set.
This type alters the binding of the argument value to the statement parameter
placeholder to indicate that the value should be encoded using the national
character set directly.
# Example
This example assumes that the following test table exists in the database:
```sql
CREATE TABLE test_character_data (
id NUMBER GENERATED ALWAYS AS IDENTITY,
text VARCHAR2(97),
ntext NVARCHAR2(99)
)
```
```rust
# #[cfg(feature="blocking")]
# fn main() -> sibyl::Result<()> {
# let session = sibyl::test_env::get_session()?;
use sibyl::NChar;
let stmt = session.prepare("
INSERT INTO test_character_data (ntext) VALUES (:TEXT)
RETURNING id INTO :ID
")?;
let mut id = 0;
let spring_ocean = "春の海 ひねもすのたり のたりかな";
stmt.execute((
("TEXT", NChar(spring_ocean)),
("ID", &mut id)
))?;
let stmt = session.prepare("
BEGIN
SELECT ntext INTO :TEXT FROM test_character_data WHERE id = :ID;
END;
")?;
let mut haiku = String::with_capacity(99);
stmt.execute((
("TEXT", NChar(&mut haiku)),
("ID", id)
))?;
assert_eq!(haiku.as_str(), spring_ocean);
# Ok(())
# }
# #[cfg(feature="nonblocking")]
# fn main() {}
```
*/
where T: ToSql + NCharForm;