是否有可能從oracle函數返回null?oracle函數中的可爲空返回類型
我有以下Oracle功能:
create or replace function vta.GetAmount(p_month NUMBER)
return number is
v_amount number(9);
begin
select amount
into v_amount
from salary
where salary.month = p_month;
return v_amount;
end GetAmount;
當select語句返回零行,它會引發以下異常: ora-01403: no data found
。
在這種情況下,我希望函數返回null。
你的SELECT語句返回超過1行對於該代碼失敗,不是因爲它返回0行。如果它將返回0行,您將返回null。 – anudeepks
不,如果它返回了0行,那麼你會得到no_data_found異常。 – Boneist
嘗試從工資 運行僅此, 選擇量 其中salary.month =: 和看到的結果; –
anudeepks