其實那個函數處理並不復雜
還有一個要注意的問題
自定義函數如下
CREATE OR REPLACE FUNCTION fn_ipaddr_to_province (p_ipaddr NUMBER)
RETURN VARCHAR
IS
v_ret VARCHAR
BEGIN
BEGIN
SELECT province
INTO v_ret
FROM ipdb
WHERE start_ip <= p_ipaddr AND end_ip >= p_ipaddr AND ROWNUM =
EXCEPTION
WHEN NO_DATA_FOUND
THEN
v_ret :=
END;
RETURN v_ret;
EXCEPTION
WHEN OTHERS
THEN
RAISE;
END fn_ipaddr_to_province;
/
根據省份確定服務器地址
方法一
BEGIN
SELECT serverip
INTO v_serverip
FROM domainname
WHERE province = fn_ipaddr_to_province (p_ip) AND ROWNUM =
EXCEPTION
WHEN NO_DATA_FOUND
THEN
v_serverip :=
END;
這種方法 CPU 使用率
方法二
v_province := fn_ipaddr_to_province (p_ip);
BEGIN
SELECT serverip
INTO v_serverip
FROM domainname
WHERE province = v_province AND ROWNUM =
EXCEPTION
WHEN NO_DATA_FOUND
THEN
v_serverip :=
END;
這種方法 CPU 使用率
From:http://tw.wingwit.com/Article/program/Oracle/201311/18095.html