
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
63 lines
1.5 KiB
Plaintext
63 lines
1.5 KiB
Plaintext
== Why is this an issue?
|
|
|
|
``++NCHAR++`` and ``++NVARCHAR2++`` lengths must be given in characters, not bytes. This is partly because a single character may occupy more than a single byte in memory. Specify the field length in bytes, and theoretically your value could overrun the field, but instead Oracle simply refuses to run the code. Specify it in characters, and Oracle will allocate the appropriate number of bytes to store the requested number of characters. Trying to specify the length semantics in bytes will result in the ``++PLS-00639: NCHAR/NVARCHAR2 cannot be byte length semantics++`` exception being raised.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,sql]
|
|
----
|
|
DECLARE
|
|
foo NCHAR(42 BYTE); -- Noncompliant - raises PLS-00639
|
|
BEGIN
|
|
NULL;
|
|
END;
|
|
/
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,sql]
|
|
----
|
|
DECLARE
|
|
foo NCHAR(42); -- Compliant
|
|
bar NCHAR(42 CHAR); -- Also compliant, as an alternative
|
|
BEGIN
|
|
NULL;
|
|
END;
|
|
/
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Specify the size of "xxx" in chars.
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 8 May 2015, 15:06:11 Dinesh Bolkensteyn wrote:
|
|
LGTM, except the ``++ Specify the field length in bytes, and your value could overrun the field.++`` bit.
|
|
|
|
|
|
There is no buffer overflow risk, as Oracle refuses to run that code.
|
|
|
|
=== on 8 May 2015, 17:39:43 Ann Campbell wrote:
|
|
Updated. See if it's okay please [~dinesh.bolkensteyn]
|
|
|
|
|
|
|
|
=== on 11 May 2015, 06:00:17 Dinesh Bolkensteyn wrote:
|
|
LGTM
|
|
|
|
endif::env-github,rspecator-view[]
|