CREATE OR REPLACE FUNCTION F1(i_UnitId VARCHAR,i_CityId VARCHAR)RETURN VARCHAR2 AS v_SendFlag VARCHAR2(2); -- 发送结果标识 ERR_INPUT_PARA EXCEPTION; -- 输入参数异常 TYPE v_TagCursor IS REF CURSOR; -- 查询结果集BEGIN v_SendFlag := '0'; IF i_CityId IS NULL THEN -- 如果城市为空 v_TagCursor IS (SELECT A.TAGID FROM T1 A WHERE A.TIME BETWEEN SYSDATE AND SYSDATE - 1 AND A.UNITID = i_UnitId); ELSE -- 城市非空 v_TagCursor IS (SELECT A.TAGID FROM T1 A
WHERE A.TIME BETWEEN SYSDATE AND SYSDATE - 1 AND A.UNITID = i_UnitId
AND A.CITYID = i_CityId); END IF; IF v_TagCursor IS NULL THEN v_SendFlag := '0';
ELSE v_SendFlag := '1';
END IF; RETURN v_SendFlag;EXCEPTION WHEN ERR_INPUT_PARA THEN RETURN '1'; WHEN OTHERS THEN RETURN '1';END F1;
BIG阳
holdtom
相关分类