rspec/rules/S2453/plsql/rule.adoc
2022-02-04 16:28:24 +00:00

59 lines
1.1 KiB
Plaintext

For fixed-length values, a ``++CHAR++`` field occupies the same amount of disk space as a ``++VARCHAR2++`` field, but for variable-length values ``++CHAR++`` fields use more storage space and make searching more difficult by right-padding values with whitespaces. Therefore ``++VARCHAR2++`` fields are preferred. Similarly, ``++NCHAR++`` should be replaced by ``++NVARCHAR2++``.
Note that for 1-character fields, ``++CHAR++`` is naturally equivalent to ``++VARCHAR2++``, but the latter is still preferred for consistency.
== Noncompliant Code Example
[source,sql]
----
DECLARE
var1 CHAR; -- Noncompliant
var2 CHAR(42); -- Noncompliant
var3 NCHAR; -- Noncompliant
var4 NCHAR(42); -- Noncompliant
BEGIN
NULL;
END;
/
----
== Compliant Solution
[source,sql]
----
DECLARE
var1 VARCHAR2(42);
var2 VARCHAR2(42);
var3 NVARCHAR2(42);
var4 NVARCHAR2(42);
BEGIN
NULL;
END;
/
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]