第一種:唯讀。參數是唯讀,不能修改,即調用時傳遞進來的是常量,或者變數(但變數不能在預存程序中修改)。通常select及DML類型的預存程序傳遞的是in類型的參數。
第二種:唯寫。忽略調用語句傳遞的任何參數,並在函數(過程)內部給這些參數賦值,因此是唯寫的。(這種情況是在函數或過程內部給參數重新賦值,但重新賦值後的參數是無法被外部調用的(好像遊標類型的參數除外))
CREATE OR REPLACE PROCEDURE "SCOTT"."SWAP" (firstValue out
number, secondValue out number) is
temp number;
begin
temp := firstValue;
firstValue := secondValue;
secondValue := temp;
end swap;
外部調用:
set serveroutput on;
declare
firstVal number;
secondVal number;
begin
firstVal := 10;
secondVal := 20;
scott.swap(firstVal,secondVal);
dbms_output.put_line('first is ' || firstVal);
dbms_output.put_line('second is ' || secondVal);
end;
無法在外部存取到firstValue與secondValue的值。此時列印出的結果為:
first is
second is
第三種:讀或寫。這可以完全控制參數,讀取傳遞的參數的值。可以再函數(過程)內部修改參數的值,在退出函數(過程)後,這些參數被賦給在函數內部寫入的值,這樣就可以返回多個值。(即入口參數寫入值後,可以傳遞到函數(過程)的外部,供外部調用的時候使用)
ps:函數中的傳回值為如下幾種:
char; varchar2; number; integer; date; boolean; table; record