-- Aggiunta vincolo not null sulle date inizio e fine isola dela tabella AABSISOL_TAB
ALTER TABLE AABSISOL_TAB
ADD CONSTRAINT aabsisol_tab_cknull1 CHECK 
(data_inizio is not null and data_fine is not null) enable novalidate
/




-- Aggiunta campi su AABSPARC_TAB

alter table AABSPARC_TAB add  
(ID_INVIO	NUMBER,
CAMPAGNA	NUMBER(4),
CUAA	VARCHAR2(16),
DATA_INS	Date)
/

ALTER TABLE AABSPARC_TAB
ADD CONSTRAINT AABSPARC_TAB_cknull1 CHECK 
(ID_INVIO is not null ) enable novalidate
/

ALTER TABLE AABSPARC_TAB
ADD CONSTRAINT AABSPARC_TAB_cknull2 CHECK 
(CAMPAGNA is not null ) enable novalidate
/

ALTER TABLE AABSPARC_TAB
ADD CONSTRAINT AABSPARC_TAB_cknull3 CHECK 
(CUAA is not null ) enable novalidate
/

ALTER TABLE AABSPARC_TAB
ADD CONSTRAINT AABSPARC_TAB_cknull4 CHECK 
(DATA_INS is not null ) enable novalidate
/

 
 
 -- Aggiunta campi su AABSAPAG_TAB

alter table AABSAPAG_TAB add  
(ID_INVIO	NUMBER,
DATA_INS	Date)
/

ALTER TABLE AABSAPAG_TAB
ADD CONSTRAINT AABSAPAG_TAB_cknull1 CHECK 
(ID_INVIO is not null ) enable novalidate
/

ALTER TABLE AABSAPAG_TAB
ADD CONSTRAINT AABSAPAG_TAB_cknull2 CHECK 
(DATA_INS is not null ) enable novalidate
/


-- Creazione collection per i servizi di gestione delle domande DU


create or replace TYPE AABSPARC_DU_REC FORCE AS OBJECT ( 
CAMPAGNA NUMBER,
CUAA VARCHAR2(100),
ID_ATTO_AMMI number,
ID_SCHEDA varchar2(100),  
ID_PARC number,           
ID_INTE number,
SUPERFICIE number,        
SHAPE MDSYS.SDO_GEOMETRY,  
COD_COLT VARCHAR2(100) )
/ 
create or replace TYPE AABSPARC_DU_COL AS TABLE OF AABSPARC_DU_REC
/ 
CREATE PUBLIC SYNONYM AABSPARC_DU_REC FOR AABSPARC_DU_REC
/
CREATE PUBLIC SYNONYM AABSPARC_DU_COL FOR AABSPARC_DU_COL
/
CREATE SEQUENCE  AABS_DG_INVIO  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 100 NOORDER  NOCYCLE 
/
