很多PL/SQL程序員采用一個命名約定區分不同作用域內的變量
create or replace function myfunc(p_empno integer) return varchar
is
l_ename emp
begin
select ename into l_ename
from emp
where empno = p_empno;
return l_ename;
end myfunc;
/
show errors;
PL/SQL有一個有趣的命名作用域系統
create or replace function myfunc(empno integer) return varchar
is
ename emp
begin
select ename into myfunc
from emp
where empno = myfunc
return myfunc
end myfunc;
/
show errors;
我知道最少有一個專業組織已經在第二個方法中為其命名約定制定了標准
這個作用域系統實際上帶來了一個奇怪的問題
create or replace package p
as
function test return varchar
end p
/
show errors;
create or replace package body p
as
function test return varchar
as
begin
return
end test;
end p
/
show errors;
create or replace package p
as
function p
end p
/
show errors;
create or replace package body p
as
function p
as
return p
end p
end p
/
show errors;
Warning: Package Body created with compilation errors
Errors for PACKAGE BODY P
LINE/COL ERROR
自己測試一下這些PL/SQL命名作用域系統的竅門
From:http://tw.wingwit.com/Article/program/SQLServer/201311/22122.html