CREATE OR REPLACE FUNCTION XIAOYAN_D(PHONENUMBER IN VARCHAR2) RETURN NUMBER AS FAN NUMBER(11); BEGIN SELECT LTRIM(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(PHONENUMBER, ' ', ''), '(', ''), ')', ''), '+', ''), '-', ''), '860') INTO FAN FROM DUAL; --对手机号做清洗处理 IF LENGTH(FAN) != 11 THEN RETURN ''; ELSIF REPLACE(TRANSLATE(FAN, '0123456789', '0'), '0', '') IS NOT NULL THEN DBMS_OUTPUT.PUT_LINE(FAN || '不是[0-9]的数字序列'); RETURN ''; ELSIF SUBSTR(FAN, 1, 3) NOT IN ('139', '138', '137', '136', '134', '135', '147', '150', '151', '152', '157', '158', '159', '172', '178','182','183','184','187','188','195','197','198', '130', '131', '132', '140', '145', '146', '155', '156','158', '166', '185', '186', '175', '176', '196', '133', '149', '153', '177', '173', '180', '181', '189', '191', '193', '199', '162', '165', '167', '170', '171') THEN DBMS_OUTPUT.PUT_LINE('前三位数字不合法:' || SUBSTR(FAN, 1, 3)); RETURN ''; ELSE DBMS_OUTPUT.PUT_LINE('合法号码'); RETURN FAN; END IF; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('异常:'); DBMS_OUTPUT.PUT_LINE(SQLCODE||sqlerrm); RETURN ''; END XIAOYAN_D;
标签:DBMS,RETURN,手机号,REPLACE,FAN,效验,Oracle,OUTPUT,LINE From: https://www.cnblogs.com/erguai/p/16853292.html