-- ----------------------------------------------------------- LOADING OF DATA: load_param
--                                                                           1999.04.22 ft
--
update load_param set topic_name            = 'not filled'  where topic_name             is NULL;
update load_param set unit_name             = 'not filled'  where unit_name              is NULL;
update load_param set aggregation_descr     = '*not filled' where aggregation_descr      is NULL;
update load_param set reference_method      = '*not filled' where reference_method       is NULL;
update load_param set storage1              = '*not filled' where storage1               is NULL;
update load_param set storage2              = '*not filled' where storage2               is NULL;
update load_param set storage3              = '*not filled' where storage3               is NULL;
update load_param set storage4              = '*not filled' where storage4               is NULL;
update load_param set data_access_id        = 0             where data_access_id         is NULL;
update load_param set access_structure_name = '*not filled' where access_structure_name  is NULL;
update load_param set access_structure_descr= 'not filled'  where access_structure_descr is NULL;
update load_param set modification_date     = SYSDATE       where modification_date      is NULL;
--
-- ------------------------------------------------------- entering data into DATA_ACCESS:
create or replace view DATA_ACCESS_HELP as
  select distinct ACCESS_STRUCTURE.access_structure_id, 0 rec_structure_id,
       STORAGE1.storage_id storage1_id, STORAGE2.storage_id storage2_id, 
       STORAGE3.storage_id storage3_id, STORAGE4.storage_id storage4_id, modification_date
  from LOAD_PARAM, ACCESS_STRUCTURE, STORAGE1, STORAGE2, STORAGE3, STORAGE4
 where LOAD_PARAM.access_structure_name = ACCESS_STRUCTURE.access_structure_name
   and LOAD_PARAM.storage1              = STORAGE1.storage_name
       and STORAGE1.storage_name        is not null
   and LOAD_PARAM.storage2              = STORAGE2.storage_name
       and STORAGE2.storage_name        is not null
   and LOAD_PARAM.storage3              = STORAGE3.storage_name
       and STORAGE3.storage_name        is not null
   and LOAD_PARAM.storage4              = STORAGE4.storage_name
       and STORAGE4.storage_name        is not null;
--
insert into DATA_ACCESS (data_access_id,  access_structure_id, rec_structure_id,
       storage1_id, storage2_id, storage3_id, storage4_id, modification_date)
 select         SEQ_DATA_ACCESS.nextval,  access_structure_id, rec_structure_id,
       storage1_id, storage2_id, storage3_id, storage4_id, modification_date
  from DATA_ACCESS_HELP;
--
-- ------------------------------------------------ entering data into PARAMETER relation:
insert into PARAMETER (entry_id,       topic_id,      unit_id,                  spatial_data_org_id,
                   aggregation_id, data_org_id,             data_access_id)
  select               entry_id, TOPIC.topic_id, UNIT.unit_id, SPATIAL_DATA_ORG.spatial_data_org_id, 
       AGGREGATION.aggregation_id,           0, DATA_ACCESS.data_access_id
  from LOAD_PARAM, TOPIC, UNIT, SPATIAL_DATA_ORG, AGGREGATION, DATA_ACCESS,
       ACCESS_STRUCTURE, STORAGE1, STORAGE2, STORAGE3, STORAGE4
 where LOAD_PARAM.topic_name           = TOPIC.topic_name
   and LOAD_PARAM.unit_name            = UNIT.unit_name
   and LOAD_PARAM.aggregation_descr    = AGGREGATION.aggregation_descr
   and LOAD_PARAM.reference_method     = SPATIAL_DATA_ORG.reference_method
   and LOAD_PARAM.modification_date    = DATA_ACCESS.modification_date
   and LOAD_PARAM.access_structure_name= ACCESS_STRUCTURE.access_structure_name
   and LOAD_PARAM.storage1             = STORAGE1.storage_name
   and   STORAGE1.storage_id           =   DATA_ACCESS.storage1_id
   and LOAD_PARAM.storage2             = STORAGE2.storage_name
   and   STORAGE2.storage_id           =   DATA_ACCESS.storage2_id
   and LOAD_PARAM.storage3             = STORAGE3.storage_name
   and   STORAGE3.storage_id           =   DATA_ACCESS.storage3_id
   and LOAD_PARAM.storage4             = STORAGE4.storage_name
   and   STORAGE4.storage_id           =   DATA_ACCESS.storage4_id;

