Langsung ke konten utama

Fungsi sederhana pada oracle

  CREATE OR REPLACE FUNCTION f_get_btp_status(vCustNbr varchar)
  return number as
  cnt number;
  v_Count       NUMBER;
  v_count_rev   number;
begin

select /*+ FIRST_ROWS(1)*/ count(0) INTO v_Count
        from btp_tbl a, indolive.prospect b, indolive.customer_tbl c

       where b.prospect_nbr = a.prospect_nbr and c.customer_id = b.ref_cust_id
       and c.customer_nbr=vCustNbr;
       
select /*+ FIRST_ROWS(1)*/ count(0) INTO v_Count_rev
        from btp_reverse a, indolive.prospect b, indolive.customer_tbl c
       where b.prospect_nbr = a.prospect_nbr and c.customer_id = b.ref_cust_id
       and c.customer_nbr=vCustNbr and a.prospect_pnrk in ('TDK ADA DI PNRK','BELUM DITARIK'); 

      
       if (v_Count = 0 or v_Count_rev= 1 ) THEN
          return 0;
       else
         select /*+ FIRST_ROWS(1)*/ count(0) INTO cnt
            from btp_tbl a, indolive.prospect b, indolive.customer_tbl c

           where b.prospect_nbr = a.prospect_nbr and c.customer_id = b.ref_cust_id
           and a.btp_status_code in(4,12) and c.customer_nbr=vCustNbr and (reason_btp_code like '1%' or reason_btp_code = '3002') ;

           if cnt > 0 THEN
              return 1;
           else
             return 0;
           end if;

       END IF;

end; 

Komentar

Popular Posts

Extjs html class render

Ext.select('.datepicker').each(function(el){ new Ext.form.DateField({ allowBlank : true, renderTo: el, format:'m-d-Y', editable:false, width:140, fieldCls : 'tanggal x-form-field x-form-text x-trigger-noedit', }); }); Ext.select('.note').each(function(el){ new Ext.form.field.TextArea({ allowBlank : false, renderTo: el, grow : true, hideLabel : true, fieldCls : 'pesan x-form-field x-form-text x-trigger-noedit', }); });