0
我有一個表,它的內容:如何找到爲例外的原因列在Oracle
ID A B
--- --- ----
1 123 &%df
2 587 364
的函數寫爲無效號碼(以下腳本)
CREATE OR REPLACE FUNCTION is_number RETURN number IS
A_var number(15);
B_var number(15);
BEGIN
for u in (select id,
A,
B,
from TABLE_NAME) LOOP
BEGIN
select
to_number(u.A),
to_number(u.B),
into A_var , B_var
from dual;
EXCEPTION
WHEN others THEN
update TABLE_NAME set ?????? = null where id = u.id;
END;
END LOOP;
return -1;
END is_number;
頂部腳本我要將??????
替換爲列名作爲無效數字,在此示例中列名稱爲B
後面的腳本,表格內容爲:
ID A B
--- --- ----
1 123
2 587 364
這是簡單salution但是如果你有100列,對於任何的必須申報嘗試捕捉那麼代碼將是大 –
我要爲列無效數據設置爲空值
不需要切換的情況下 –
轉換,出現異常處理只在嵌套函數'custom_to_number'中實現一次。 – ksa