oracle函数 code实例

CREATE OR REPLACE FUNCTION gettaxcycle (
      vv02           IN   vv02_accounts_tin%ROWTYPE,
      returnoption   IN   NUMBER

   )
      RETURN NUMBER
   AS
      tr12rec    tr12_accounts_tin%ROWTYPE;
      tg05rec    tg05_tax_type_details%ROWTYPE;
      taxcycle   NUMBER;

   BEGIN

      SELECT *
        INTO tg05rec

        FROM tg05_tax_type_details
       WHERE cg02_tax_type = vv02.cg02_tax_type;

      CASE returnoption
         WHEN 1
         THEN
            IF tg05rec.cg05_ass_cycle IS NULL
            THEN
               tg05rec.cg05_ass_cycle := 1;
            END IF;

            taxcycle := tg05rec.cg05_ass_cycle;
         WHEN 2
         THEN
            IF tg05rec.cg05_pro_r_filing_cycle IS NULL
            THEN
               tg05rec.cg05_pro_r_filing_cycle := 1;
            END IF;

            taxcycle := tg05rec.cg05_pro_r_filing_cycle;
      END CASE;

      RETURN taxcycle;
   END gettaxcycle;



你可能感兴趣的:(Oracle函数)