			/* ---------------------------------------------------------------------------- */
/* AB3901T00 - TECNICOS ENTIDAD */
/* ---------------------------------------------------------------------------- */

CREATE TABLE AB39A.AB3901T00
(
	CODTECNICO         NUMBER(6) NOT NULL,
	BAJA               NUMBER(1) DEFAULT 0 NOT NULL,
	DOCIDENTIFICACION  VARCHAR2(10) NOT NULL,
	TIPOIDENTIF			NUMBER(2) NOT NULL,
	NOMBRE             VARCHAR2(100) NOT NULL,
	APE1               VARCHAR2(100) NOT NULL,
	APE2               VARCHAR2(100) NULL,
	TELEFONO1          VARCHAR2(30),
	TELEFONO2          VARCHAR2(30),
	EMAIL              VARCHAR2(100),
	SEXO               VARCHAR2(1),
	CALLE              VARCHAR2(100),
	NUMCALLE           VARCHAR2(6),
	CODPOSTAL          VARCHAR2(5),
	MUNICIPIO          VARCHAR2(3),
	PROVINCIA          VARCHAR2(2),
	LOCALIDAD		   NUMBER(15)
) TABLESPACE  AB3901E00;

ALTER TABLE AB39A.AB3901T00 ADD CONSTRAINT PK_AB3901T00 PRIMARY KEY (CODTECNICO) USING INDEX TABLESPACE AB3902E00;
ALTER INDEX AB39A.PK_AB3901T00 REBUILD TABLESPACE AB3902E00;

/* ---------------------------------------------------------------------------- */
/* AB3902T00 - ENTIDADES */
/* ---------------------------------------------------------------------------- */

CREATE TABLE AB39A.AB3902T00
(
	CODENTIDAD        NUMBER(6) NOT NULL,
	TIPO_ENTIDAD      NUMBER(1) NOT NULL,
	BAJA				NUMBER(1) DEFAULT 0 NOT NULL,
	DESENTIDAD        VARCHAR2(150) NOT NULL,
	CIFNIF            VARCHAR2(10) NOT NULL,
	TIPOIDENTIF			NUMBER(2) NOT NULL,
	CODTH             VARCHAR2(2) NOT NULL,
	CODMUN            VARCHAR2(3) NULL,
	NUM_CALLE         NUMBER(8),
	NUM_TRABAJADORES  NUMBER(8),
	NUM_TRAB_HOMBRE   NUMBER(8),
	NUM_TRAB_MUJER    NUMBER(8),
	TFNO              NUMBER(9),
	CP                VARCHAR2(5),
	DIRECCION         VARCHAR2(100),
	EMAIL             VARCHAR2(50),
	SOLICINFOR	      NUMBER(1) DEFAULT 0,
	LOCALIDAD	      NUMBER(15),
	MUNICIPIOTXT	  VARCHAR2(100),
	LOCALIDADTXT 	  VARCHAR2(100)
) TABLESPACE  AB3901E00;

ALTER TABLE AB39A.AB3902T00 ADD CONSTRAINT PK_AB3902T00 PRIMARY KEY (CODENTIDAD) USING INDEX TABLESPACE AB3902E00;
ALTER INDEX AB39A.PK_AB3902T00 REBUILD TABLESPACE AB3902E00;

/* ---------------------------------------------------------------------------- */
/* AB3903T00 - TIPO_ORGANIZACION */
/* ---------------------------------------------------------------------------- */

CREATE TABLE AB39A.AB3903T00
(
	ID_TIPOORGANIZACION  NUMBER(2) NOT NULL,
	DESCRIPCION          VARCHAR2(100) NOT NULL,
	DESCRIPCIONES        VARCHAR2(100) NOT NULL
) TABLESPACE  AB3901E00;

ALTER TABLE AB39A.AB3903T00 ADD CONSTRAINT PK_AB3903T00 PRIMARY KEY (ID_TIPOORGANIZACION) USING INDEX TABLESPACE AB3902E00;
ALTER INDEX AB39A.PK_AB3903T00 REBUILD TABLESPACE AB3902E00;

/* ---------------------------------------------------------------------------- */
/* AB3904T00 - EJE */
/* ---------------------------------------------------------------------------- */

CREATE TABLE AB39A.AB3904T00
(
	ID_EJE               NUMBER(3) NOT NULL,
	ORDEN                NUMBER(3) NOT NULL,
	PONDERACION          NUMBER(3) NOT NULL,
	ID_TIPOORGANIZACION  NUMBER(2) NOT NULL,
	NOMBRE               VARCHAR2(250) NOT NULL,
	NOMBRECAS            VARCHAR2(250) NOT NULL,
	HELBURU              VARCHAR2(500) NOT NULL,
	HELBURUCAS           VARCHAR2(500) NOT NULL
) TABLESPACE  AB3901E00;

ALTER TABLE AB39A.AB3904T00 ADD CONSTRAINT PK_AB3904T00 PRIMARY KEY (ID_EJE) USING INDEX TABLESPACE AB3902E00;
ALTER INDEX AB39A.PK_AB3904T00 REBUILD TABLESPACE AB3902E00;

/* ---------------------------------------------------------------------------- */
/* AB3905T00 - ELEMENTO */
/* ---------------------------------------------------------------------------- */

CREATE TABLE AB39A.AB3905T00
(
	ID_ELEMENTO       NUMBER(6) NOT NULL,
	ORDEN             NUMBER(3) NOT NULL,
	NIVEL             NUMBER(3) NOT NULL,
	PONDERACION       NUMBER(3) NOT NULL,
	TIENEEUS 		  NUMBER(1) DEFAULT 0 NOT NULL,
	TIENEELEBI        NUMBER(1) DEFAULT 0 NOT NULL,
	TIENEVALOR		  NUMBER(1) DEFAULT 0 NOT NULL,
	PUEDEACCION 	  NUMBER(1) DEFAULT 0 NOT NULL,
	PUEDENUEVOELEM	  NUMBER(1) DEFAULT 0 NOT NULL,
	NOMBRE            VARCHAR2(250) NOT NULL,
	NOMBRECAS         VARCHAR2(250) NOT NULL,
	ID_EJE            NUMBER(3),
	ID_ELEMENTOPADRE  NUMBER(6),
	HELBURU           VARCHAR2(500),
	HELBURUCAS        VARCHAR2(500)
) TABLESPACE  AB3901E00;

ALTER TABLE AB39A.AB3905T00 ADD CONSTRAINT PK_AB3905T00 PRIMARY KEY (ID_ELEMENTO) USING INDEX TABLESPACE AB3902E00;
ALTER INDEX AB39A.PK_AB3905T00 REBUILD TABLESPACE AB3902E00;


/* ---------------------------------------------------------------------------- */
/* AB3906T00 - ACCIONES */
/* ---------------------------------------------------------------------------- */

CREATE TABLE AB39A.AB3906T00
(
    IDACCION    NUMBER(6) NOT NULL,
	IDELEMENTO  NUMBER(6) NOT NULL,
	ORDEN       NUMBER(3) DEFAULT 0 NOT NULL,
	NOMBREEUS   VARCHAR2(250) NOT NULL,
	NOMBRECAS   VARCHAR2(250) NOT NULL
) TABLESPACE  AB3901E00;

ALTER TABLE AB39A.AB3906T00 ADD CONSTRAINT PK_AB3906T00 PRIMARY KEY (IDACCION) USING INDEX TABLESPACE AB3902E00;
ALTER INDEX AB39A.PK_AB3906T00 REBUILD TABLESPACE AB3902E00;

/* ---------------------------------------------------------------------------- */
/* AB3907T00 - PLANES_ESTRATEGICOS */
/* ---------------------------------------------------------------------------- */

CREATE TABLE AB39A.AB3907T00
(
	CODPLANE                   NUMBER(6) NOT NULL,
	CODVERSION				NUMBER(3) DEFAULT 1 NOT NULL,
	CODENTIDAD                 NUMBER(6) NOT NULL,
	ANYOINICIO                 NUMBER(4) NOT NULL,
	ANYOFIN                    NUMBER(4) NOT NULL,
	ACTIVO						NUMBER(1) DEFAULT 0 NOT NULL,
	INDICE_OBLIGAT             NUMBER(3) DEFAULT 0 NOT NULL,
	NIVEL_CUMPLIMIENTO_REQEUS  NUMBER(3) DEFAULT 0 NOT NULL,
	PORCENTAJE_BILIN			NUMBER(3) DEFAULT 0 NOT NULL,
	FECHA_ALTA				DATE DEFAULT SYSDATE NOT NULL,
	CODPLANIFICACION           NUMBER(3) NULL,
	FECHA_ACEPTACION_PLAN      DATE,
	NOMBRE                     VARCHAR2(250) NULL,
	NOMBREEUS                  VARCHAR2(250) NULL,
	SOLICITAR_TXOSTENA         NUMBER(1) DEFAULT 0 NOT NULL,
	BAJA						NUMBER(1) DEFAULT 0 NOT NULL,
	CODTECNICOBAJA				NUMBER(6) NULL,
	FECHA_BAJA					DATE NULL
) TABLESPACE  AB3901E00;

ALTER TABLE AB39A.AB3907T00 ADD CONSTRAINT PK_AB3907T00 PRIMARY KEY (CODPLANE,CODVERSION) USING INDEX TABLESPACE AB3902E00;
ALTER INDEX AB39A.PK_AB3907T00 REBUILD TABLESPACE AB3902E00;

/* ---------------------------------------------------------------------------- */
/* AB3908T00 - ELEMENTOS_PE */
/* ---------------------------------------------------------------------------- */

CREATE TABLE AB39A.AB3908T00
(
	CODELEMENTOPE       NUMBER(6) NOT NULL,
	CODPLANE            NUMBER(6) NOT NULL,
	CODVERSIONPE        NUMBER(3) NOT NULL,
	ELEMBASE            NUMBER(1) DEFAULT 0 NOT NULL,
	ORDEN               NUMBER(3) DEFAULT 0 NOT NULL,
	NIVEL               NUMBER(3) DEFAULT 0 NOT NULL,
	HAS_EUS             NUMBER(3) DEFAULT 0 NOT NULL,
	HAS_ELEBI           NUMBER(3) DEFAULT 0 NOT NULL,
	AURRE_EUS           NUMBER(3) DEFAULT 0 NOT NULL,
	AURRE_ELEBI         NUMBER(3) DEFAULT 0 NOT NULL,
	AMAI_EUS            NUMBER(3) DEFAULT 0 NOT NULL,
	AMAI_ELEBI          NUMBER(3) DEFAULT 0 NOT NULL,
	HAS_VALOR           NUMBER(3) DEFAULT 0 NOT NULL,
	AURRE_VALOR         NUMBER(3) DEFAULT 0 NOT NULL,
	AMAI_VALOR          NUMBER(3) DEFAULT 0 NOT NULL,
	TIENEEUS          NUMBER(1) DEFAULT 0 NOT NULL,
	TIENEELEBI          NUMBER(1) DEFAULT 0 NOT NULL,
	TIENEVALOR          NUMBER(1) DEFAULT 0 NOT NULL,
	TIENESINO           NUMBER(1) DEFAULT 0 NOT NULL,
	HAS_SINO			NUMBER(1) DEFAULT 0 NOT NULL,
	AURRE_SINO			NUMBER(1) DEFAULT 0 NOT NULL,
	AMAI_SINO			NUMBER(1) DEFAULT 0 NOT NULL,
	IDELEMENTO          NUMBER(6) NULL,
	CODELEMENTOPEPADRE  NUMBER(6) NULL,
	NOMBRE              VARCHAR2(250) NULL,
	NOMBRECAS           VARCHAR2(250) NULL,
	HELBURU             VARCHAR2(500) NULL,
	HELBURUCAS          VARCHAR2(500) NULL,
	OHARRAK             VARCHAR2(500) NULL
) TABLESPACE  AB3901E00;

ALTER TABLE AB39A.AB3908T00 ADD CONSTRAINT PK_AB3908T00 PRIMARY KEY (CODELEMENTOPE) USING INDEX TABLESPACE AB3902E00;
ALTER INDEX AB39A.PK_AB3908T00 REBUILD TABLESPACE AB3902E00;

/* ---------------------------------------------------------------------------- */
/* AB3909T00 - PLANES_GESTION */
/* ---------------------------------------------------------------------------- */

CREATE TABLE AB39A.AB3909T00
(
	CODPLANG  NUMBER(6) NOT NULL,
	CODPLANE  NUMBER(6) NOT NULL,
	ANYO      NUMBER(4) NOT NULL,
	NOMBRE    VARCHAR2(250) NULL,
	NOMBREEUS VARCHAR2(250) NULL,
	BAJA						NUMBER(1) DEFAULT 0 NOT NULL,
	CODTECNICOBAJA				NUMBER(6) NULL,
	FECHA_BAJA					DATE NULL
) TABLESPACE  AB3901E00;

ALTER TABLE AB39A.AB3909T00 ADD CONSTRAINT PK_AB3909T00 PRIMARY KEY (CODPLANG) USING INDEX TABLESPACE AB3902E00;
ALTER INDEX AB39A.PK_AB3909T00 REBUILD TABLESPACE AB3902E00;

/* ---------------------------------------------------------------------------- */
/* AB3910T00 - ELEMENTOS_PG */
/* ---------------------------------------------------------------------------- */

CREATE TABLE AB39A.AB3910T00
(
	CODELEMPG       NUMBER(6) NOT NULL,
	CODPLANG        NUMBER(6) NOT NULL,
	ELEMBASE        NUMBER(1) DEFAULT 0 NOT NULL,
	ORDEN           NUMBER(3) DEFAULT 0 NOT NULL,
	NIVEL           NUMBER(3) DEFAULT 0 NOT NULL,
	IDELEMENTO		NUMBER(6) NULL,
	NOMBRE          VARCHAR2(250) NULL,
	NOMBRECAS       VARCHAR2(250) NULL,
	CODELEMENTOPE   NUMBER(6), 
	CODELEMPGPADRE  NUMBER(6)
) TABLESPACE  AB3901E00;

ALTER TABLE AB39A.AB3910T00 ADD CONSTRAINT PK_AB3910T00 PRIMARY KEY (CODELEMPG) USING INDEX TABLESPACE AB3902E00;
ALTER INDEX AB39A.PK_AB3910T00 REBUILD TABLESPACE AB3902E00;

/* ---------------------------------------------------------------------------- */
/* AB3911T00 - ACCIONES_PG */
/* ---------------------------------------------------------------------------- */

CREATE TABLE AB39A.AB3911T00
(
	CODACCIONPG         NUMBER(6) NOT NULL,
	CODELEMPG           NUMBER(6) NOT NULL,
	NUMRECEPTORES       NUMBER(6) DEFAULT 0 NOT NULL,
	NUMRECEPH           NUMBER(3) DEFAULT 0 NOT NULL,
	NUMRECEPM           NUMBER(3) DEFAULT 0 NOT NULL,
	CODSITUACIONFINAL   NUMBER(1) DEFAULT 0 NOT NULL,
	ORDEN               NUMBER(3) DEFAULT 0 NOT NULL,
	ELEMBASE            NUMBER(1) DEFAULT 0 NOT NULL,
	NOMBRE              VARCHAR2(250) NULL,
	NOMBRECAS           VARCHAR2(250) NULL,
	NUEVAFECHAPREV      DATE NULL,
	IDACCION            NUMBER(6) NULL,
	RESPONSABLE         VARCHAR2(150) NULL,
	FECHAPREV           DATE NULL,
	CODTIPORECEPTOR     NUMBER(2) NULL,
	RAZON_APLAZA        VARCHAR2(250) NULL,
	RAZON_APLAZA_CAS    VARCHAR2(250) NULL,
	MOTIVO_CANCELA      VARCHAR2(250) NULL,
	MOTIVO_CANCELA_CAS  VARCHAR2(250) NULL,
	DESCRIPCION         VARCHAR2(500) NULL,
	DESCRIPCIONCAS      VARCHAR2(500) NULL,
	OBSERVACIONES       VARCHAR2(500) NULL,
	OBSERVACIONESCAS    VARCHAR2(500) NULL,
	RESULTHECHA         NUMBER(1) NULL
) TABLESPACE  AB3901E00;


ALTER TABLE AB39A.AB3911T00 ADD CONSTRAINT PK_AB3911T00 PRIMARY KEY (CODACCIONPG) USING INDEX TABLESPACE AB3902E00;
ALTER INDEX AB39A.PK_AB3911T00 REBUILD TABLESPACE AB3902E00;

/* ---------------------------------------------------------------------------- */
/* AB3912T00 - TIPOS_RECEPTORES */
/* ---------------------------------------------------------------------------- */

CREATE TABLE AB39A.AB3912T00
(
	CODTIPORECEP  NUMBER(3) NOT NULL,
	DESCAS        VARCHAR2(100) NOT NULL,
	DESEUS        VARCHAR2(100) NOT NULL
) TABLESPACE  AB3901E00;

ALTER TABLE AB39A.AB3912T00 ADD CONSTRAINT PK_AB3912T00 PRIMARY KEY (CODTIPORECEP) USING INDEX TABLESPACE AB3902E00;
ALTER INDEX AB39A.PK_AB3912T00 REBUILD TABLESPACE AB3902E00;

/* ---------------------------------------------------------------------------- */
/* AB3913T00 - PLANIFICACION */
/* ---------------------------------------------------------------------------- */

CREATE TABLE AB39A.AB3913T00
(
	CODPLANIFICACION  NUMBER(3) NOT NULL,
	FECHAINICIO       NUMBER(4) NOT NULL,
	FECHAFIN          NUMBER(4) NOT NULL,
	BAJA			  NUMBER(1) NOT NULL,
	DESCAS            VARCHAR2(100) NOT NULL,
	DESEUS            VARCHAR2(100) NOT NULL
) TABLESPACE  AB3901E00;

ALTER TABLE AB39A.AB3913T00 ADD CONSTRAINT PK_AB3913T00 PRIMARY KEY (CODPLANIFICACION) USING INDEX TABLESPACE AB3902E00;
ALTER INDEX AB39A.PK_AB3913T00 REBUILD TABLESPACE AB3902E00;

/* ---------------------------------------------------------------------------- */
/* AB3914T00 - EJES_PE */
/* ---------------------------------------------------------------------------- */

CREATE TABLE AB39A.AB3914T00
(
	CODPLANE    NUMBER(6) NOT NULL,
	CODVERSIONPE	NUMBER(3) DEFAULT 1 NOT NULL,
	ID_EJE      NUMBER(3) NOT NULL,
	HELBURU     VARCHAR2(500) NULL,
	HELBURUCAS  VARCHAR2(500) NULL
) TABLESPACE  AB3901E00;

ALTER TABLE AB39A.AB3914T00 ADD CONSTRAINT PK_AB3914T00 PRIMARY KEY (CODPLANE,CODVERSIONPE,ID_EJE) USING INDEX TABLESPACE AB3902E00;
ALTER INDEX AB39A.PK_AB3914T00 REBUILD TABLESPACE AB3902E00;

/* ---------------------------------------------------------------------------- */
/* AB3915T00 - ENTIDAD_TECNICO */
/* ---------------------------------------------------------------------------- */

CREATE TABLE AB39A.AB3915T00
(
	CODENTIDAD  NUMBER(6) NOT NULL,
	CODTECNICO  NUMBER(6) NOT NULL
) TABLESPACE  AB3901E00;

ALTER TABLE AB39A.AB3915T00 ADD CONSTRAINT PK_AB3915T00 PRIMARY KEY (CODENTIDAD,CODTECNICO) USING INDEX TABLESPACE AB3902E00;
ALTER INDEX AB39A.PK_AB3915T00 REBUILD TABLESPACE AB3902E00;

/* ---------------------------------------------------------------------------- */
/* AB3916T00 - TIPOS_IDENTIF */
/* ---------------------------------------------------------------------------- */

CREATE TABLE AB39A.AB3916T00
(
	CODIGO  NUMBER(2) NOT NULL,
	DESCAS  VARCHAR2(50) NOT NULL,
	DESEUS  VARCHAR2(50) NOT NULL
) TABLESPACE  AB3901E00;

ALTER TABLE AB39A.AB3916T00 ADD CONSTRAINT PK_AB3916T00 PRIMARY KEY (CODIGO) USING INDEX TABLESPACE AB3902E00;
ALTER INDEX AB39A.PK_AB3916T00 REBUILD TABLESPACE AB3902E00;


/* ---------------------------------------------------------------------------- */
/* AB3917T00 - PLANESESTR_TECNICOS */
/* ---------------------------------------------------------------------------- */

CREATE TABLE AB39A.AB3917T00
(
	CODPLANE    NUMBER(6) NOT NULL,
	CODTECNICO  NUMBER(6) NOT NULL
) TABLESPACE  AB3901E00;

ALTER TABLE AB39A.AB3917T00 ADD CONSTRAINT PK_AB3917T00 PRIMARY KEY (CODPLANE,CODTECNICO) USING INDEX TABLESPACE AB3902E00;
ALTER INDEX AB39A.PK_AB3917T00 REBUILD TABLESPACE AB3902E00;


COMMIT;
EXIT;