2020-06-30 12:48:39 +02:00
|
|
|
Trying to assign a large character value to a smaller variable or column will raise an error.
|
|
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
|
|
|
|
----
|
|
|
|
create table persons (id number, name varchar2(4));
|
|
|
|
|
|
|
|
insert into persons (id, name) values (1, 'Alice'); -- Noncompliant, raises ORA-12899
|
|
|
|
|
|
|
|
create or replace procedure sp1
|
|
|
|
is
|
|
|
|
foo varchar2(2);
|
|
|
|
begin
|
|
|
|
select name into foo from persons where id = 1; -- Noncompliant, may raise ORA-06502
|
|
|
|
end;
|
|
|
|
----
|
|
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
|
|
|
|
----
|
|
|
|
create table persons (id number, name varchar2(8));
|
|
|
|
|
|
|
|
insert into persons (id, name) values (1, 'Alice');
|
|
|
|
|
|
|
|
create or replace procedure sp1
|
|
|
|
is
|
|
|
|
foo varchar2(8);
|
|
|
|
begin
|
|
|
|
select name into foo from persons where id = 1;
|
|
|
|
end;
|
|
|
|
----
|
|
|
|
|
|
|
|
include::../see.adoc[]
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-06-08 15:52:13 +02:00
|
|
|
'''
|
2021-06-02 20:44:38 +02:00
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../comments-and-links.adoc[]
|
2021-06-03 09:05:38 +02:00
|
|
|
endif::env-github,rspecator-view[]
|