欢迎各位兄弟 发布技术文章
这里的技术是共享的
--oracle sql疑难解析
create or replace function isnum(v_in varchar2) return varchar is
val_err exception;
pragma exception_init(val_err,-6502);
scrub_num number;
begin
scrub_num:=to_number(v_in);
return 'Y';
exception when val_err then
return 'N';
end;
来自 https://blog.csdn.net/aoerqileng/article/details/46507049
原始出处:
http://www.plsqlchallenge.com/
作者:Steven Feuerstein
运行环境:SQLPLUS, SERVEROUTPUT已打开
哪些选项创建了一个名为PLCH_IS_WONDERFUL的函数,使得下列代码块执行之后:
BEGIN
DBMS_OUTPUT.put_line (plch_is_wonderful ('CHOCOLATE'));
DBMS_OUTPUT.put_line (plch_is_wonderful ('BROKEN LEG'));
END;
/
你会在屏幕上按所示顺序看到如下的文本:
YES
NO
(A)
CREATE OR REPLACE FUNCTION plch_is_wonderful (thing_in IN VARCHAR2)
RETURN VARCHAR2
IS
BEGIN
IF thing_in = 'CHOCOLATE'
THEN
RETURN 'YES';
END IF;
RAISE PROGRAM_ERROR;
EXCEPTION
WHEN PROGRAM_ERROR
THEN
RETURN 'NO';
END plch_is_wonderful;
/
(B)
CREATE OR REPLACE FUNCTION plch_is_wonderful (thing_in IN VARCHAR2)
RETURN VARCHAR2
IS
BEGIN
IF thing_in = 'CHOCOLATE'
THEN
RETURN 'YES';
ELSE
RETURN 'NO';
END IF;
END plch_is_wonderful;
/
(C)
CREATE OR REPLACE FUNCTION plch_is_wonderful (thing_in IN VARCHAR2)
RETURN VARCHAR2
IS
BEGIN
RETURN C ASE thing_in WHEN 'CHOCOLATE' THEN 'YES' ELSE 'NO' END;
END plch_is_wonderful;
/
(D)
CREATE OR REPLACE FUNCTION plch_is_wonderful (thing_in IN VARCHAR2)
RETURN VARCHAR2
IS
e_is_wonderful EXCEPTION;
e_is_not_wonderful EXCEPTION;
BEGIN
IF thing_in = 'CHOCOLATE'
THEN
RAISE e_is_wonderful;
ELSE
RAISE e_is_not_wonderful;
END IF;
EXCEPTION
WHEN e_is_wonderful
THEN
RETURN 'NO';
WHEN e_is_not_wonderful
THEN
RETURN 'YES';
END plch_is_wonderful;
来自 https://blog.csdn.net/zhq200902/article/details/55194245