日期:2014-05-16  浏览次数:20412 次

NO_DATA_FOUND和||变量组装和for循环的代码实例

?

BEGIN
  BEGIN
    SELECT MC_XZQH INTO RESULT FROM DM_XZQH WHERE DM_XZQH = V_DM_XZQH;
  EXCEPTION
    WHEN NO_DATA_FOUND THEN
      V_ISEXISTS := 'FALSE';
  END;
  IF V_ISEXISTS = 'FALSE' THEN
    RESULT := '';
  END IF;
  RETURN(RESULT);
END F_GETXZQHMC_BYDM;

?

?

字符串拼接:

    SELECT COUNT(*)
      INTO V_BTBZCOUNT
      FROM DM_SX_BTXM A, XX_SX_BTXM B
     WHERE A.DM_BTXM = B.DM_BTXM
       AND A.DM_SX_BTXM = B.DM_SX_BTXM
       AND A.DM_BTXM = VI_DM_BTXM
       AND B.DM_XZQH = VI_XZQH
       AND B.BTND = VI_BTND
       AND A.LX_SX_BTXM = '1'
       AND A.XY_BZ = 'Y'
       AND B.XY_BZ = 'Y'
       AND V_BTGS LIKE '%{' || A.DM_SX_BTXM || '}%'; --被补贴公式使用

?

for循环:

    FOR i in 1 .. (JB_DIFF_COUNT - 1) loop
      SELECT DM_XZQH_PARENT
        INTO VI_SJ_XZQH_PARENT
        FROM DM_XZQH
       WHERE DM_XZQH = VI_SJ_XZQH_PARENT;
    END LOOP;
?