Skip to content

Commit cd70a1f

Browse files
change severity of G-2310 to blocker
because using char instead of varchar2 can lead to unexpected behavior or to a bug.
1 parent dbbc32e commit cd70a1f

File tree

1 file changed

+21
-1
lines changed
  • docs/4-language-usage/2-variables-and-types/3-character-data-types

1 file changed

+21
-1
lines changed

docs/4-language-usage/2-variables-and-types/3-character-data-types/g-2310.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# G-2310: Avoid using CHAR data type.
22

3-
!!! warning "Major"
3+
!!! bug "Blocker"
44
Reliability
55

66
## Reason
@@ -17,6 +17,26 @@ end types_up;
1717
/
1818
```
1919

20+
Unexpected trailing spaces can lead to wrong results.
21+
22+
```sql
23+
with
24+
dept as (
25+
select cast(department_name as varchar2(30 char)) as dname_vc2
26+
,cast(department_name as char(30 char)) as dname_char
27+
from departments
28+
)
29+
select count(*)
30+
from dept
31+
where dname_vc2 = dname_char;
32+
```
33+
34+
```
35+
COUNT(*)
36+
----------
37+
0
38+
```
39+
2040
## Example (good)
2141

2242
``` sql

0 commit comments

Comments
 (0)