Obsidian/Recognition/Programing/Tibero/function Table.md

2.3 KiB



CREATE OR REPLACE TYPE obj_type AS object
( c1 INT,
  c2 INT
);

CREATE OR REPLACE TYPE table_type  AS TABLE OF obj_type;




CREATE OR REPLACE FUNCTION table_func (p_start int, p_end int)
  RETURN table_type
  IS
    v_type TABLE_TYPE := table_type();
  BEGIN
   
    FOR i IN p_start..p_end LOOP
      v_type.extend;
      v_type(i) := obj_type(i,i);
    END LOOP;
     
    RETURN v_type;
 END;
 /
 
 CREATE OR REPLACE FUNCTION pipe_table_func(p_start INT, p_end INT)
  RETURN table_type1
  PIPELINED
  IS
    v_type obj_type1;
  BEGIN
    FOR i IN p_start..p_end LOOP
      v_type := obj_type1(i, i);
      PIPE ROW(v_type);
    END LOOP;
  END;
 /



CREATE OR REPLACE FUNCTION ucm.table_func (std_date varchar)
  RETURN ucm.schdul_table_type
  IS
    v_type ucm.schdul_table_type := ucm.schdul_table_type();
    
   i number;
   
   v_obj ucm.schdul_type := ucm.schdul_type(null, null, null, null, null, null, null, null, null, null
                                         , null, null, null, null, null, null, null, null, null, null
                                         , null, null, null, null, null, null, null, null, null, null
                                         , null, null, null, null, null, null, null, null, null, null
                                         , null, null, null, null, null, null, null, null, null, null
                                         , null, null, null, null, null, null, null);
   v_obj_init  ucm.schdul_type;
   
   V_STAND_NO VARCHAR(10);
   V_CCTV_YN VARCHAR(1);
   
   CURSOR C_Stand_List IS
   select ucm.FUN_PRE_ZERO_REMOVE(replace(a.stand_no, '00', '')) as stand_no
          , decode(b.STAND_NO, null, 'N', 'Y') as cctv_yn
    from ucm.SACP_STAND a, ucm.SACP_CCTVID_MAPPING b
    where a.STAND_NO = b.STAND_NO (+)
   
   
  BEGIN
   
   FOR cRet IN C_ACDM_RCV LOOP
   
       begin
       
            select 'A' as flt_se, b.STAND_NO , flt_sttus, trgt_id, clsgn, ac_reg_no, arr_no, if_dt, rwy_id, exp_stand_on_dt, actl_stand_on_dt, actl_arr_dt, acdm_sttus_cd
            from uic.V_FLT_ARR_STAND b 
            where stand_no = cRet.stand_no;
            
       
       EXCEPTION WHEN others THEN
       
       
       end ;
   
   END LOOP;
   
    FOR i IN 1..20 LOOP
    
      v_type.extend;
      v_type(i) := v_obj;
    END LOOP;
     
    RETURN v_type;
 END;
 /