rspec/rules/S4575/plsql/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
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.
2023-05-25 14:18:12 +02:00

39 lines
1.3 KiB
Plaintext

== Why is this an issue?
The ``++TO_DATE++`` and ``++TO_TIMESTAMP++`` functions are converting char of ``++CHAR++``, ``++VARCHAR2++``, ``++NCHAR++``, or ``++NVARCHAR2++`` datatype to respectively a value of ``++DATE++`` or ``++TIMESTAMP++`` datatype.
Without providing the format of the input char, ``++TO_DATE++`` will consider the provided char is compliant with the default date format. Relying on a default configuration is a source of error because it creates a dependency between the code and the configuration of the ORACLE server where this code is deployed.
According to the Oracle's documentation "the default date format is determined implicitly by the NLS_TERRITORY initialization parameter or can be set explicitly by the NLS_DATE_FORMAT parameter.". It means the behaviour of the ``++TO_DATE++`` function will certainly not be the expected one if the configuration of the ORACLE server is changing.
=== Noncompliant code example
[source,sql]
----
SELECT TO_DATE( 'January 15, 2018, 11:00 A.M.')
FROM DUAL;
----
=== Compliant solution
[source,sql]
----
SELECT TO_DATE( 'January 15, 2018, 11:00 A.M.', 'Month dd, YYYY, HH:MI A.M.')
FROM DUAL;
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Provide the format of the input char.
endif::env-github,rspecator-view[]