Skip to main content

Package body parameters should match the specification's NOCOPY qualification

ZPA rule for PL/SQL and Oracle SQL · PackageBodyParameterNocopy

NOCOPY asks Oracle to pass an OUT or IN OUT parameter by reference. Oracle accepts a body whose parameter differs from the specification's in this, without an error or a warning. The two headings then disagree: a reader of the specification and a reader of the body see different promises about how the argument is passed, and what happens to it when the subprogram raises an error.

This rule reports a parameter of a package body subprogram whose NOCOPY differs from the same parameter in the package specification, when the project resolves that specification.

Examples​

Noncompliant Code Example
create package body label_pkg as
-- the specification declares p_text in out nocopy clob
procedure append_footer(p_text in out clob) is -- Noncompliant
begin
p_text := p_text || chr(10) || 'end of label';
end;
end;
Compliant Solution
create package body label_pkg as
procedure append_footer(p_text in out nocopy clob) is
begin
p_text := p_text || chr(10) || 'end of label';
end;
end;