自定义oracle 函数的运用

CREATE OR REPLACE FUNCTION USF_GET_CS_FAC_PUR_MULTI_DSCP
/*
      Copyright(c) 2007 xxx
      20080314 : Initial Creation by xxx
*/
(
  fac_id_in        IN TBL_FAC_PUR.FAC_ID%TYPE
)
RETURN VARCHAR2
AS
    RETURN_FAC_DSCP NVARCHAR2(2000);
    v_record     NVARCHAR2(2000);
    V_MT_FAC_DSCP_CUR TYPES.cursor_type;
BEGIN
  BEGIN
    RETURN_FAC_DSCP := ' ';
    OPEN V_MT_FAC_DSCP_CUR FOR
SELECT TBL_MT_FAC_PUR.DSCP
           FROM TBL_MT_FAC_PUR
           INNER JOIN TBL_FAC_PUR ON TBL_FAC_PUR.MT_FAC_PUR_CD = TBL_MT_FAC_PUR.CD
           WHERE TBL_FAC_PUR.FAC_ID = fac_id_in;
         LOOP
          FETCH V_MT_FAC_DSCP_CUR INTO v_record;
            EXIT WHEN V_MT_FAC_DSCP_CUR%NOTFOUND;

          IF RETURN_FAC_DSCP = ' ' THEN
            RETURN_FAC_DSCP := v_record;
          ELSE
            RETURN_FAC_DSCP := RETURN_FAC_DSCP || ', ' || v_record;
          END IF;
        END LOOP;
  END;
  RETURN RETURN_FAC_DSCP;
END;

你可能感兴趣的:(oracle,C++,c,C#)