44 lines
817 B
Plaintext
44 lines
817 B
Plaintext
At most one declaration of a variable in a given scope is allowed in PL/SQL. The ``++PLS-00371++`` error will be raised at runtime when attempting to reference a variable declared more than once.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
[source,sql]
|
|
----
|
|
SET SERVEROUTPUT ON
|
|
|
|
DECLARE
|
|
foo VARCHAR2(42) := 'foo';
|
|
foo VARCHAR2(42) := 'bar'; -- Non-Compliant
|
|
BEGIN
|
|
DBMS_OUTPUT.PUT_LINE(foo); -- Raises PLS-00371: at most one declaration for 'FOO' is permitted
|
|
END;
|
|
/
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
[source,sql]
|
|
----
|
|
SET SERVEROUTPUT ON
|
|
|
|
DECLARE
|
|
foo VARCHAR2(42) := 'foo';
|
|
bar VARCHAR2(42) := 'bar'; -- Compliant
|
|
BEGIN
|
|
DBMS_OUTPUT.PUT_LINE(foo);
|
|
END;
|
|
/
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::message.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|