BEGIN
  FOR l_rec IN (SELECT table_name
                  FROM user_tables
                 WHERE table_name IN ('EXT_COSTS', 'EXT_LABOUR_COSTS', 'EXT_MATERIAL_COSTS')) LOOP
    EXECUTE IMMEDIATE 'DROP TABLE '||l_rec.table_name;
  END LOOP;
END;
/
create table ext_labour_costs
(
  netw01_selling_price  varchar2(240),
  netw02_selling_price  varchar2(240),
  netw03_selling_price  varchar2(240),
  netw04_selling_price  varchar2(240),  
  netw05_selling_price  varchar2(240),
  netw06_selling_price  varchar2(240),
  netw07_selling_price  varchar2(240),
  netw08_selling_price  varchar2(240),
  valid_from  varchar2(240),
  valid_to    varchar2(240),
  enty_code   varchar2(240),
  mesc_code   varchar2(240),
  svcpt_code  varchar2(240),
  mety_code   varchar2(240)
   )  
   ORGANIZATION EXTERNAL
( type oracle_loader
default directory webmip_bulk_load
access parameters
( records delimited by NEWLINE
  READSIZE 10485760
  skip 3
  fields terminated by "," optionally enclosed by '"'
  missing field values are NULL
  (
  netw01_selling_price,
  netw02_selling_price,
  netw03_selling_price,
  netw04_selling_price,  
  netw05_selling_price,
  netw06_selling_price,
  netw07_selling_price,
  netw08_selling_price,
  valid_from,
  valid_to,
  enty_code,
  mesc_code,
  svcpt_code,
  mety_code
  )
)
location ('LABOUR_COSTS.csv')
)
reject limit unlimited
/
create table ext_material_costs
(
  selling_price  varchar2(240),
  cost_price     varchar2(240),
  delivery_cost  varchar2(240),
  valid_from     varchar2(240),  
  valid_to       varchar2(240),
  cost_type      varchar2(240),
  modu_code      varchar2(240),
  hou_code       varchar2(240),
  bas_code       varchar2(240),
  adit_code      varchar2(240)
   )  
   ORGANIZATION EXTERNAL
( type oracle_loader
default directory webmip_bulk_load
access parameters
( records delimited by NEWLINE
  READSIZE 10485760
  skip 2
  fields terminated by "," optionally enclosed by '"'
  missing field values are NULL
  (
  selling_price,
  cost_price,
  delivery_cost,
  valid_from,  
  valid_to,
  cost_type,
  modu_code,
  hou_code,
  bas_code,
  adit_code
  )
)
location ('MATERIAL_COSTS.csv')
)
reject limit unlimited
/
