oracle create a function to catch exceptions

 

CREATE OR REPLACE FUNCTION Fun_getbirthDayfromIdntity (Idntity IN VARCHAR2) - defines the parameters
/ * The ID number acquisition date of birth * /
the RETURN DATE
the IS
Birthday DATE; - defined return value

bx_exception EXCEPTION; - defined exception variable
BEGIN

SELECT to_date(substr(Idntity,7,8),'yyyy-MM-dd') INTO birthday FROM dual; --赋值

RAISE bx_exception;--捕获异常
EXCEPTION
WHEN others THEN NULL;--

RETURN (birthday); - Returns
END Fun_getbirthDayfromIdntity; - End

Guess you like

Origin www.cnblogs.com/tanhu/p/11316765.html