3
說我有下面的包(請留意評論):優勢內部程序的前置聲明在PL/SQL包
Create or replace package test_package_fdec as
procedure ext_proc1;
procedure ext_proc2;
end test_package_fdec;
/
Create or replace package body test_package_fdec as
procedure int_proc; -- forward declaration
procedure int_proc2 -- explicit internal procedure declaration
is
begin
dbms_output.put_line('this is int_proc2');
end int_proc2;
procedure ext_proc1
is
begin
dbms_output.put_line('Welcome to StackOverflow');
dbms_output.put_line('i will use an internal procedures with Forward Declarations');
int_proc;
end ext_proc1;
procedure ext_proc2
is
begin
dbms_output.put_line('Welcome to Oracle Forums');
dbms_output.put_line('i will use an internal procedures without Forward Declarations');
int_proc2;
end ext_proc2;
procedure int_proc
is
begin
dbms_output.put_line('used forward declaration');
end int_proc;
end test_package_fdec;
什麼是內部包體採用提前聲明的優勢/劣勢程序? 它對性能有影響嗎? 同樣,在宣言部分明確寫出內部程序有沒有優勢/劣勢?
在我的文章'int_proc'中使用forward聲明是否是最佳實踐?或者只是明確地定義像int_proc2這樣的內部過程?謝謝! –
這只是一個最佳實踐,如果有充分的理由去做。在你的例子中很難說它是否重要,因爲名字只是個例子,並沒有多大意義。如果你的包只是一堆代碼扔在一起,而不是重新排序這些過程,所以你不需要前向聲明。但是,如果您努力使程序像書中的章節那樣,那麼順序可能很重要,您可能需要使用前向聲明來支持邏輯順序。 –