/*******************************************************************************
 * Selected metadata objects
 * -------------------------
 * Extracted at 05/08/2005 03:49:43 p.m.
 ******************************************************************************/

/*******************************************************************************
 * Sequences
 * ---------
 * Extracted at 05/08/2005 03:49:43 p.m.
 ******************************************************************************/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.DETALLE_SOLICITUD_CP_GEN
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INC_SALDOS_PENDIENTES
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCIP
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCLOGRELOJX
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMABONNE
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMAPPEL
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMBN
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMBNINT
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMCAMBIO
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMEC
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMHIST
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMID_RECHABONNE
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMIMP
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMITV
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMLOGIN
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMLOTEX
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMMAIL
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMMOUVEMENT
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMORDREPPV
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMPAYAV
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMRDV
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMRECH
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMRECU
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMROLE
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMSOC
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMSTATRECO
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMVENTE
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCNUMVISITE
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCPAGO
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.INCTRANSACDLAX
  MINVALUE 1
  CACHE 20
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE SEQUENCE LOGIC_021.SOLICITUD_CABIO_PRECIO_GEN
  MINVALUE 1
  CACHE 20
/

/*******************************************************************************
 * Tables
 * ------
 * Extracted at 05/08/2005 03:49:43 p.m.
 ******************************************************************************/

CREATE TABLE LOGIC_021.ABONNE (
    NUMABONNE Number(10) NOT NULL,
    NUMSOUSCRIPT Number(10),
    NUMCONTRAT Number(10),
    GENRE VarChar2(1),
    NOM VarChar2(50),
    LGT VarChar2(4),
    CODINSEE VarChar2(3),
    ADRESSE VarChar2(100),
    BOITPOST VarChar2(15),
    TELDOM VarChar2(14),
    TELBURO VarChar2(14),
    TELCEL VarChar2(14),
    DTABON Date,
    DTSAISIE Date,
    LETWLC VarChar2(3),
    CODOPE VarChar2(10),
    RUTA Number(10),
    CBOR VarChar2(4),
    NATION VarChar2(10),
    CAUTION Number,
    TRAVAIL VarChar2(20),
    CODRGT VarChar2(4),
    NUMTVA VarChar2(10),
    SOLDE Number,
    LOCALIZATION VarChar2(5),
    CEDULA VarChar2(20),
    NUMID Number(10),
    INTERNET VarChar2(62),
    HABITACION Number(5),
    LIMITPPV Number,
    ASUJETIV VarChar2(1),
    VENCELGT Date,
    TIPO VarChar2(1),
    NITREAL VarChar2(25),
    NUME_HOGAR VarChar2(8),
    CPROV VarChar2(3),
    CCANTON VarChar2(3),
    CDISTRI VarChar2(3),
    CLAVEDLA VarChar2(8),
    TIPOFACT VarChar2(4),
    TELFAX VarChar2(14),
    MULTA VarChar2(1),
    TEMPORAL Number(10),
    GESTION VarChar2(1),
    MOTIVO_GESTION VarChar2(3),
    FECHA_GESTION Date,
    GESTOR VarChar2(10),
    CONSTRAINT RDB$PRIMARY25 PRIMARY KEY (
      NUMABONNE
    )
)
/

CREATE TABLE LOGIC_021.ABONNEPPV (
    NUMORDREPPV Number(10) NOT NULL,
    NUMABONNE Number(10),
    DTSAISIE Date,
    NUMTRANSACDLA Number(10),
    NUMEVENT Number(10),
    NUMSERIE VarChar2(15),
    DTFACT Date,
    CONSTRAINT RDB$PRIMARY49 PRIMARY KEY (
      NUMORDREPPV
    )
)
/

CREATE TABLE LOGIC_021.ABONNEPPVPROB (
    NUMORDREPPV Number(10) NOT NULL,
    DTSAISIE Date,
    NUMSERIE VarChar2(15),
    NUMABONNE Number(10),
    CONSTRAINT RDB$PRIMARY50 PRIMARY KEY (
      NUMORDREPPV
    )
)
/

CREATE TABLE LOGIC_021.ACTUALIZACION (
    NUMABONNE Number(10) NOT NULL,
    OPTICNODE VarChar2(9),
    NUMTAP VarChar2(9),
    SORTIETAP Number(5),
    CONSTRAINT RDB$PRIMARY83 PRIMARY KEY (
      NUMABONNE
    )
)
/

CREATE TABLE LOGIC_021.AG (
    NUMABONNE Number(10) NOT NULL,
    SOLD1 Number(14, 2),
    SOLD2 Number(14, 2),
    SOLD3 Number(14, 2),
    SOLD4 Number(14, 2),
    SOLD5 Number(14, 2),
    CONSTRAINT SYS_C009940 PRIMARY KEY (
      NUMABONNE
    )
)
/

CREATE TABLE LOGIC_021.AMNETINFO (
    FICHEID Number(4) NOT NULL,
    PRECIOS CLOB,
    CANALES CLOB,
    NOTICIAS CLOB,
    TELEFONO CLOB,
    PROMOCION CLOB,
    AVERIAS CLOB,
    COBERINTERNET CLOB,
    VENTAS CLOB,
    RHUMANO CLOB,
    INFOLOGIC CLOB,
    INFORADIOS CLOB,
    CONSTRAINT SYS_C009942 PRIMARY KEY (
      FICHEID
    )
)
/

CREATE TABLE LOGIC_021.AVERINTERNET (
    NUMLLAMADA Number(10) NOT NULL,
    NUMABONNE Number(10) NOT NULL,
    NUMOT Number(10),
    FECHAINI Date,
    HORAINI VarChar2(5),
    USUARIOINI VarChar2(10),
    MOTIVO VarChar2(4),
    RESPUESTA VarChar2(4),
    OBSERVACION Long,
    ESTADO VarChar2(1) NOT NULL,
    GRUPOLATE VarChar2(4),
    FECHAFINAL Date,
    HORAFINAL VarChar2(5),
    USUARIOFIN VarChar2(10),
    NUMCASO Number(10),
    PRIORIDAD Number(10),
    CONSTRAINT RDB$PRIMARY51 PRIMARY KEY (
      NUMLLAMADA
    )
)
/

CREATE TABLE LOGIC_021.BITACORA_NODOS (
    CODIGO_HEADEND VarChar2(5) NOT NULL,
    CODIGO_HUB VarChar2(5) NOT NULL,
    NUMNODE VarChar2(10) NOT NULL,
    FECHA Date NOT NULL,
    HORA Number(10) NOT NULL,
    ESTADO Number(10) NOT NULL,
    USUARIO VarChar2(10) NOT NULL,
    COMENTARIO VarChar2(250),
    CONSTRAINT RDB$PRIMARY209 PRIMARY KEY (
      CODIGO_HEADEND,
      CODIGO_HUB,
      NUMNODE,
      FECHA,
      HORA,
      ESTADO
    )
)
/

CREATE TABLE LOGIC_021.BLOCNOTE (
    NUMBN Number(10) NOT NULL,
    NUMABONNE Number(10),
    DTSAISIE Date,
    LIB VarChar2(50),
    CODOPE VarChar2(10),
    CONSTRAINT RDB$PRIMARY13 PRIMARY KEY (
      NUMBN
    )
)
/

CREATE TABLE LOGIC_021.CABLEMODEMSERV (
    ORDRE Number(10) NOT NULL,
    NUMSERIE VarChar2(40),
    MACADDRESS VarChar2(15),
    TIPOEQUIPO VarChar2(12),
    FECHAVENCIM Date,
    NUMCLIALOPA VarChar2(10),
    PROPIETARIO VarChar2(10),
    POLITICA VarChar2(10),
    CONSTRAINT RDB$PRIMARY84 PRIMARY KEY (
      ORDRE
    )
)
/

CREATE TABLE LOGIC_021.CAJACAJERO (
    NUMMOUVEMENT Number(10) NOT NULL,
    HEURE VarChar2(5),
    DTCPT Date,
    CASHIER VarChar2(10),
    CASHEFECTIVOCOL Number,
    CASHEFECTIVODOL Number,
    CASHCHEQUECOL Number,
    CASHCHEQUEDOL Number,
    CASHBANCODEPOSIT Number,
    CASHDIFER Number,
    CASHVOUCHERCREST Number,
    CASHVOUCHERCREDOMATIC Number,
    CASHVOUCHERAVAL Number,
    CASHDIFERCANAL Number,
    CASHDIFERSISTEMAS Number,
    "COMMENT" VarChar2(200),
    CAMBIO Number,
    COMISION Number,
    DIFERCAMBIO Number,
    DIFERCORTE Number,
    PCOBRAREMPLEA Number,
    DIFERCAJERO Number,
    CONSTRAINT RDB$PRIMARY37 PRIMARY KEY (
      NUMMOUVEMENT
    )
)
/

CREATE TABLE LOGIC_021.CAJAPRINC (
    NUMMOUVEMENT Number(10) NOT NULL,
    HEURE VarChar2(5),
    CODOPE VarChar2(10),
    DTCPT Date,
    NUMLOTE VarChar2(10),
    CASHIER VarChar2(10),
    TOTEFECTIVO Number,
    TOTCHEQUE Number,
    TOTBANCRECEN Number,
    TOTCREDOMATIC Number,
    TOTAVAL Number,
    TOTOTRO Number,
    TOTCREST Number,
    TOTBANCO Number,
    CASHEFECTIVOCOL Number,
    CASHEFECTIVODOL Number,
    CASHCHEQUECOL Number,
    CASHCHEQUEDOL Number,
    CASHBANCODEPOSIT Number,
    CASHDIFER Number,
    CASHVOUCHERCREST Number,
    CASHVOUCHERCREDOMATIC Number,
    CASHVOUCHERAVAL Number,
    CASHDIFERCANAL Number,
    CASHDIFERSISTEMAS Number,
    "COMMENT" VarChar2(200),
    CAMBIO Number,
    COMISION Number,
    TOTBSJ Number,
    DIFERCAMBIO Number,
    DIFERCORTE Number,
    PCOBRAREMPLEA Number,
    DIFERCAJERO Number,
    TIPO VarChar2(5),
    OFICINA VarChar2(4),
    AVALMILLAS Number,
    TOTAVALMILLAS Number,
    CASHAVALMILLAS Number,
    DIFERAVALMILLAS Number,
    CONSTRAINT RDB$PRIMARY36 PRIMARY KEY (
      NUMMOUVEMENT
    )
)
/

CREATE TABLE LOGIC_021.CAMBIOCOLILLA (
    NUMCAMBIO Number(10) NOT NULL,
    NUMABONNE Number(10) NOT NULL,
    NUMSOUSCRIPT Number(10),
    NOM VarChar2(50),
    DTSAISIE Date,
    CODOPE VarChar2(10),
    CONSTRAINT RDB$PRIMARY33 PRIMARY KEY (
      NUMCAMBIO
    )
)
/

CREATE TABLE LOGIC_021.CANTONES (
    CCANTON VarChar2(3) NOT NULL,
    NCANTON VarChar2(50),
    CPROV VarChar2(2) NOT NULL,
    CPAIS VarChar2(3) NOT NULL,
    CONSTRAINT CANTONES_PK PRIMARY KEY (
      CCANTON,
      CPROV,
      CPAIS
    )
)
/

CREATE TABLE LOGIC_021.CDDTRCONDI (
    NUMABONNE Number(10),
    OFICIAL VarChar2(10),
    FECHA Date,
    ESTCTA VarChar2(1),
    INST VarChar2(1),
    AVE VarChar2(1),
    TEXT VarChar2(1),
    TINST VarChar2(1),
    DEV VarChar2(1),
    DES VarChar2(1),
    RECO VarChar2(1),
    PREM VarChar2(1),
    STEC VarChar2(1),
    SALDO VarChar2(1),
    VENTAS VarChar2(1),
    VARIOS VarChar2(1),
    OBSERV VarChar2(100),
    TELEFONO VarChar2(14),
    EMISOR VarChar2(50),
    CMBTAR VarChar2(1),
    EXCTAR VarChar2(1),
    INCTAR VarChar2(1)
)
/

CREATE TABLE LOGIC_021.CIUDADES (
    CODIGO Number(10) NOT NULL,
    DESCRIPCION VarChar2(50),
    CONSTRAINT CIUDADES_PK PRIMARY KEY (
      CODIGO
    )
)
/

CREATE TABLE LOGIC_021.CLOSING (
    DTCLOS Date NOT NULL,
    CONSTRAINT RDB$PRIMARY14 PRIMARY KEY (
      DTCLOS
    )
)
/

CREATE TABLE LOGIC_021.COMMUNE (
    CODINSEE VarChar2(3) NOT NULL,
    NOM VarChar2(25),
    NBPREV Number(10),
    NUMSOC Number(5) NOT NULL,
    CONSTRAINT RDB$PRIMARY360 PRIMARY KEY (
      CODINSEE
    )
)
/

CREATE TABLE LOGIC_021.COMPTA (
    PERIODE VarChar2(7) NOT NULL,
    CAMBIO Number,
    STATUS VarChar2(4),
    CONSTRAINT RDB$PRIMARY6 PRIMARY KEY (
      PERIODE
    )
)
/

CREATE TABLE LOGIC_021.COMPTE (
    CPTNUM VarChar2(20) NOT NULL,
    LIB VarChar2(50)
)
/

CREATE TABLE LOGIC_021.CONFIGURACION (
    DESC3 Number,
    DESC6 Number,
    DESC9 Number,
    DESC12 Number,
    TIPOMULTA VarChar2(1),
    MULTA Number,
    PASSENCRYP VarChar2(1),
    AVALMILLAS Number,
    AVALMONTO Number,
    FACTORAVAL Number,
    RUTA_PPV_WIN VarChar2(30),
    RUTA_PPV_LINUX VarChar2(30),
    ALOPA VarChar2(1),
    PNODESCO VarChar2(4),
    PDESCOTRAS VarChar2(4),
    PDESCONORM VarChar2(4),
    COD_DEPOSITO VarChar2(4),
    COST_INS VarChar2(4)
)
/

CREATE TABLE LOGIC_021.CONTACTOS (
    NUMCONTACTO Number(10) NOT NULL,
    NUMABONNE Number(10) NOT NULL,
    NOMBRE VarChar2(50) NOT NULL,
    TELEFONO1 VarChar2(10),
    TELEFONO2 VarChar2(10) NOT NULL,
    EMAIL VarChar2(50),
    APARTADO VarChar2(15)
)
/

CREATE TABLE LOGIC_021.CONTRAT (
    TYPCTRT VarChar2(4),
    DTLASTMODIF Date,
    DTRESI Date,
    CODRESI VarChar2(4),
    CODRGT VarChar2(4),
    CODVDS VarChar2(4),
    CODPROV VarChar2(4),
    COMENTARIO VarChar2(100),
    NUMABONNE Number(10) NOT NULL,
    AMPLIACION VarChar2(1),
    INSINMEDIATA VarChar2(1),
    TIPOTRABAJO VarChar2(4),
    CONSTRAINT RDB$PRIMARY9 PRIMARY KEY (
      NUMABONNE
    )
)
/

CREATE TABLE LOGIC_021.CORREOS (
    NUMMAIL Number(10) NOT NULL,
    ORDRE Number(10),
    NUMINTER Number(10),
    LOGIN VarChar2(25),
    DOMINIO VarChar2(25),
    PASSWD VarChar2(20),
    CAPACITY Number,
    ESTADO VarChar2(1),
    DTSAISIE Date,
    DTMENS Date,
    DTRESI Date,
    MOVIMIENTO VarChar2(3),
    CONSTRAINT RDB$PRIMARY59 PRIMARY KEY (
      NUMMAIL
    )
)
/

CREATE TABLE LOGIC_021.CREDFISCAL (
    NUMABONNE Number(10) NOT NULL,
    NUMREGISTRO VarChar2(10),
    ACTIVIDAD VarChar2(50),
    CONSTRAINT RDB$PRIMARY60 PRIMARY KEY (
      NUMABONNE
    )
)
/

CREATE TABLE LOGIC_021.DECOLUNES (
    NUMABONNE Number(10) NOT NULL,
    SALDO Number,
    CODOPE VarChar2(10),
    DTSAISIE Date,
    NOM VarChar2(50),
    JOUR VarChar2(10),
    CODINSEE VarChar2(5),
    CONSTRAINT RDB$PRIMARY35 PRIMARY KEY (
      NUMABONNE
    )
)
/

CREATE TABLE LOGIC_021.DEMENAGE (
    NUMABONNE Number(10) NOT NULL,
    ADRESSE VarChar2(100),
    CODINSEE VarChar2(5),
    LOCALIZATION VarChar2(11),
    TELDOM VarChar2(14),
    DTRACC Date,
    CODINT VarChar2(4),
    "COMMENT" VarChar2(100),
    LOCA VarChar2(11),
    OPTICNODE VarChar2(10),
    CONSTRAINT RDB$PRIMARY407 PRIMARY KEY (
      NUMABONNE
    )
)
/

CREATE TABLE LOGIC_021.DEPOSITOS (
    NUMABONNE Number(10) NOT NULL,
    DEPOSITO Number NOT NULL,
    ESTADO VarChar2(1),
    RECIBO Number(10),
    CODOPE VarChar2(10),
    FECHA Date,
    CONSTRAINT RDB$PRIMARY86 PRIMARY KEY (
      NUMABONNE
    )
)
/

CREATE TABLE LOGIC_021.DERECHOS_REPORTE (
    GRUPO VarChar2(4),
    REPORTE VarChar2(50)
)
/

CREATE TABLE LOGIC_021.DETALLE_SOLICITUD_CP (
    ID_DETALLE Number(10) NOT NULL,
    ID_SOLICITUD Number(10) NOT NULL,
    ORDRE Number(10) NOT NULL,
    CODPROD VarChar2(4),
    NUEVO_PRECIO Number(14, 2) NOT NULL,
    CONSTRAINT PK_DETALLE_SOLICITUD_CP PRIMARY KEY (
      ID_DETALLE
    )
)
/

CREATE TABLE LOGIC_021.DETEC (
    NUMPIECE Number(10) NOT NULL,
    CODPROD VarChar2(4) NOT NULL,
    MTT Number,
    CODTVA VarChar2(4),
    NUMJRNL VarChar2(3),
    CANTIDAD Number(10),
    CONSTRAINT RDB$PRIMARY27 PRIMARY KEY (
      NUMPIECE,
      CODPROD
    )
)
/

CREATE TABLE LOGIC_021.DETECHQ (
    NUMPIECE Number(10) NOT NULL,
    NUMCHQ VarChar2(10),
    BANKCHQ VarChar2(25),
    EMISOR VarChar2(25),
    NUMCARD VarChar2(16),
    NUMAUTORIZ VarChar2(16),
    TARJETAHABIENTE VarChar2(40),
    MILLAS Number,
    PAQUETE VarChar2(4),
    CONSTRAINT RDB$PRIMARY32 PRIMARY KEY (
      NUMPIECE
    )
)
/

CREATE TABLE LOGIC_021.DETINTER (
    NUMINTER Number(10) NOT NULL,
    CODPROD VarChar2(4) NOT NULL,
    QTEDMD Number(5),
    MOVIMIENTO VarChar2(3),
    ESTADO VarChar2(1),
    ORDREVTE Number(10) NOT NULL,
    TIPO VarChar2(1),
    MOTIVO VarChar2(4),
    CONSTRAINT RDB$PRIMARY63 PRIMARY KEY (
      NUMINTER,
      ORDREVTE
    )
)
/

CREATE TABLE LOGIC_021.DETINTER_TEMP (
    NUMINTER Number(10) NOT NULL,
    ORDRE Number(10) NOT NULL,
    NUMSERIE VarChar2(15),
    CODPROD VarChar2(4) NOT NULL,
    TIPOACCION VarChar2(3),
    ACCRESULT VarChar2(50),
    OPTICNODE VarChar2(10)
)
/

CREATE TABLE LOGIC_021.DETINTERMAT (
    NUMINTER Number(10) NOT NULL,
    CODMAT VarChar2(9) NOT NULL,
    QTEINST Number(5),
    CONSTRAINT RDB$PRIMARY64 PRIMARY KEY (
      NUMINTER,
      CODMAT
    )
)
/

CREATE TABLE LOGIC_021.DICO (
    OBJID Number(10),
    VERSION Number(5),
    "NAME" VarChar2(31),
    ALIASNAME VarChar2(31),
    TYPEID Number(10),
    MISCINFO1 Number(10),
    MISCINFO2 Number(10),
    SRCOBJID Number(10),
    SRCVERSION Number(5),
    DESTOBJID Number(10),
    DESTVERSION Number(5),
    OUTOFDATE VarChar2(1),
    CREATEDATE Date,
    LASTUPDATE Date,
    INFOBLOB Long,
    MISCINFO3 Number(10)
)
/

CREATE TABLE LOGIC_021.DISTRITOS (
    CDISTRI VarChar2(3) NOT NULL,
    NDISTRI VarChar2(50),
    CCANTON VarChar2(3) NOT NULL,
    CPROV VarChar2(2) NOT NULL,
    CPAIS VarChar2(3) NOT NULL,
    CONSTRAINT DISTRITOS_PK PRIMARY KEY (
      CDISTRI,
      CCANTON,
      CPROV,
      CPAIS
    )
)
/

CREATE TABLE LOGIC_021.DROITS (
    DROIT VarChar2(4) NOT NULL,
    LIB VarChar2(25),
    SOCIO VarChar2(1),
    NUEVOSOCIO VarChar2(1),
    CONSULTSOCIO VarChar2(1),
    MODIFSOCIO VarChar2(1),
    MODIFINTERNET VarChar2(1),
    CAMBIOSERV VarChar2(1),
    REACTIV VarChar2(1),
    COMPLETEOT VarChar2(1),
    MODIFOT VarChar2(1),
    DESCO VarChar2(1),
    RECO VarChar2(1),
    TRASLADO VarChar2(1),
    COLILLA VarChar2(1),
    CONTA VarChar2(1),
    FACTURA VarChar2(1),
    PAGOCONLOTE VarChar2(1),
    REIMBULSO VarChar2(1),
    NOTACRED VarChar2(1),
    DEVUELTO VarChar2(1),
    NOTADEBITO VarChar2(1),
    PAGOSINLOTE VarChar2(1),
    RECONCIL VarChar2(1),
    LOTECAJA VarChar2(1),
    TRANSFCAJA VarChar2(1),
    CIERRE VarChar2(1),
    LOTENC VarChar2(1),
    TRANSFNC VarChar2(1),
    EDICION VarChar2(1),
    EDTCOBRADOR VarChar2(1),
    EXPORT VarChar2(1),
    PREMIUM VarChar2(1),
    TERMINAL VarChar2(1),
    PELICULAS VarChar2(1),
    COBRADOR VarChar2(1),
    MODIFLOTECOB VarChar2(1),
    MODIFCOB VarChar2(1),
    COBCREARCHIVO VarChar2(1),
    COBTRANSARCHIVO VarChar2(1),
    FACTPRORAT VarChar2(1),
    RED VarChar2(1),
    FACTURACION VarChar2(1),
    EDTSOCIO VarChar2(1),
    EDTCLIENTE VarChar2(1),
    EDTCONTA VarChar2(1),
    EDTRED VarChar2(1),
    EDTDIVERSO VarChar2(1),
    EDTOT VarChar2(1),
    ADMINISTRACION VarChar2(1),
    AGENDA VarChar2(1),
    PARAMETRO VarChar2(1),
    DECOFALTAPAGO VarChar2(1),
    CAMBIODIR VarChar2(1),
    CONSTRAINT RDB$PRIMARY197 PRIMARY KEY (
      DROIT
    )
)
/

CREATE TABLE LOGIC_021.ECRITCPT (
    NUMPIECE Number(10) NOT NULL,
    NUMABONNE Number(10),
    PERIODE VarChar2(7),
    DTCPT Date,
    DTSAISIE Date,
    NUMJRNL VarChar2(3),
    LIB VarChar2(50),
    NUMFACT Number(10),
    MTTDEB Number,
    MTTCRED Number,
    MDRGLT VarChar2(4),
    MOTIFIMP VarChar2(4),
    CODOPE VarChar2(10),
    ENCAISSE Number,
    RESTE Number,
    CODINSEE VarChar2(5),
    TYPEC VarChar2(4),
    CBOR VarChar2(4),
    RESUMANU Number(10),
    NUMLOTE VarChar2(10),
    NUMFACTURA Number(10),
    RECONCIL VarChar2(1),
    IMPRESO VarChar2(1),
    WORKTO VarChar2(4),
    FACTURA VarChar2(8),
    FECHA_HASTA Date,
    FECHA_DESDE Date,
    CODIGODEPAGO Number,
    CONSTRAINT RDB$PRIMARY4 PRIMARY KEY (
      NUMPIECE
    )
)
/

CREATE TABLE LOGIC_021.ESTADO_NODO (
    ESTADO Number(10) NOT NULL,
    DETALLE VarChar2(20),
    TIPO VarChar2(1),
    CONSTRAINT RDB$PRIMARY207 PRIMARY KEY (
      ESTADO
    )
)
/

CREATE TABLE LOGIC_021.ESTCTA_031 (
    NUMABONNE Number(10) NOT NULL,
    NUMSOUSCRIPT Number(10),
    NOM VarChar2(50),
    ADRESSE VarChar2(100),
    PERIODE VarChar2(7),
    DT Date,
    TITULOSALDO VarChar2(20),
    SOLDMESANTES Number,
    SERVICIO1 VarChar2(25),
    SERVMTT1 Number,
    SERVICIO2 VarChar2(25),
    SERVMTT2 Number,
    SERVICIO3 VarChar2(25),
    SERVMTT3 Number,
    SERVICIO4 VarChar2(25),
    SERVMTT4 Number,
    NUEVOSALDO Number,
    RUTA Number(10),
    VENCIMIENTO Date,
    TELDOM VarChar2(14),
    DESDE Date,
    HASTA Date,
    MTT5 Number,
    CBOR VarChar2(4),
    PAGODESPUES Number,
    MULTAPLICADA VarChar2(4),
    NUEVOSALDOCOL Number,
    PAGOOFICINA VarChar2(10),
    FACTURA Number(10),
    SERVICIO5 VarChar2(25),
    SERVMTT5 Number,
    SERVICIO6 VarChar2(25),
    SERVMTT6 Number,
    SERVICIO7 VarChar2(25),
    SERVMTT7 Number,
    SERVICIO8 VarChar2(25),
    SERVMTT8 Number,
    SERVICIO9 VarChar2(25),
    SERVMTT9 Number,
    SERVICIO10 VarChar2(25),
    SERVMTT10 Number,
    MULTA Number,
    FACTURA_TC Number(10),
    MONTO_MULTA Number,
    MONTO_FACTURA Number,
    MONTO_FACTURA_TC Number,
    NOTA_CRED1 VarChar2(50),
    MTT_NOTA_CRED1 Number,
    NOTA_CRED2 VarChar2(50),
    MTT_NOTA_CRED2 Number,
    NOTA_CRED3 VarChar2(50),
    MTT_NOTA_CRED3 Number,
    NOTA_CREDTC1 VarChar2(50),
    MTT_NOTA_CREDTC1 Number,
    NOTA_CREDTC2 VarChar2(50),
    MTT_NOTA_CREDTC2 Number,
    NOTA_CREDTC3 VarChar2(50),
    MTT_NOTA_CREDTC3 Number,
    QTYS1 Number(5),
    QTYS2 Number(5),
    QTYS3 Number(5),
    QTYS4 Number(5),
    QTYS5 Number(5),
    QTYS6 Number(5),
    QTYS7 Number(5),
    QTYS8 Number(5),
    QTYS9 Number(5),
    QTYS10 Number(5),
    TOTAL_IMPUESTOS Number,
    ASUJETI VarChar2(4),
    MONTOMES Number,
    DESDE1 Date,
    HASTA1 Date,
    CODPROD1 VarChar2(4),
    CODPROD2 VarChar2(4),
    CODPROD3 VarChar2(4),
    CODPROD4 VarChar2(4),
    CODPROD5 VarChar2(4),
    CODPROD6 VarChar2(4),
    CODPROD7 VarChar2(4),
    CODPROD8 VarChar2(4),
    CODPROD9 VarChar2(4),
    CODPROD10 VarChar2(4),
    ASUJETIV VarChar2(1),
    ULT_PAGO Date
)
/

CREATE TABLE LOGIC_021.FACTRECIBO (
    NUMABONNE Number(10) NOT NULL,
    NUMSOUSCRIPT Number(10),
    NOMBREPAGADOR VarChar2(50),
    ADRESSE VarChar2(100),
    PERIODE VarChar2(7),
    RUTA Number(10),
    TELDOM VarChar2(14),
    NOMBRECBOR VarChar2(25),
    SERV0 VarChar2(25),
    MTT0 Number,
    MTT0G Number,
    MTTDOL0 Number,
    SERV1 VarChar2(25),
    MTT1 Number,
    MTT1G Number,
    MTTDOL1 Number,
    SERV2 VarChar2(25),
    MTT2 Number,
    MTT2G Number,
    MTTDOL2 Number,
    SERV3 VarChar2(25),
    MTT3 Number,
    MTT3G Number,
    MTTDOL3 Number,
    SERV4 VarChar2(25),
    MTT4 Number,
    MTT4G Number,
    MTTDOL4 Number,
    SERV5 VarChar2(25),
    MTT5 Number,
    MTT5G Number,
    MTTDOL5 Number,
    SERV6 VarChar2(25),
    MTT6 Number,
    MTT6G Number,
    MTTDOL6 Number,
    SERV7 VarChar2(25),
    MTT7 Number,
    MTT7G Number,
    MTTDOL7 Number,
    SERV8 VarChar2(25),
    MTT8 Number,
    MTT8G Number,
    MTTDOL8 Number,
    SERV9 VarChar2(25),
    MTT9 Number,
    MTT9G Number,
    MTTDOL9 Number,
    SERV10 VarChar2(25),
    MTT10 Number,
    MTT10G Number,
    MTTDOL10 Number,
    SERV11 VarChar2(25),
    MTT11 Number,
    MTT11G Number,
    MTTDOL11 Number,
    TVAPROD Number,
    TOTALAPAGAR Number,
    DESDEHASTA VarChar2(20),
    FECHASPAGOS VarChar2(36),
    FACTURA Number(10),
    CONSTRAINT RDB$PRIMARY18 PRIMARY KEY (
      NUMABONNE
    )
)
/

CREATE TABLE LOGIC_021.HEADEND (
    CODIGO_HEADEND VarChar2(5) NOT NULL,
    NOMBRE_HEADEND VarChar2(25),
    CONSTRAINT RDB$PRIMARY78 PRIMARY KEY (
      CODIGO_HEADEND
    )
)
/

CREATE TABLE LOGIC_021.HISTERMINAL (
    NUMHIST Number(10) NOT NULL,
    NUMSERIE VarChar2(15),
    NUMABONNE Number(10),
    FECHAMOVI Date,
    CODOPE VarChar2(10),
    TIPOMOVIMIENTO VarChar2(3),
    "COMMENT" VarChar2(50),
    CONSTRAINT RDB$PRIMARY31 PRIMARY KEY (
      NUMHIST
    )
)
/

CREATE TABLE LOGIC_021.HISTORICO_NUMCONTRAT (
    NUMABONNE Number(10) NOT NULL,
    NUMCONTRAT_VIEJO Number(10),
    NOM VarChar2(50),
    CONSTRAINT RDB$PRIMARY55 PRIMARY KEY (
      NUMABONNE
    )
)
/

CREATE TABLE LOGIC_021.HUB (
    CODIGO_HUB VarChar2(5) NOT NULL,
    NOMBRE_HUB VarChar2(25),
    CODIGO_HEADEND VarChar2(5) NOT NULL,
    CONSTRAINT RDB$PRIMARY79 PRIMARY KEY (
      CODIGO_HUB,
      CODIGO_HEADEND
    )
)
/

CREATE TABLE LOGIC_021.IMPAYE (
    NUMIMP Number(10) NOT NULL,
    NUMPIECE Number(10) NOT NULL,
    NUMABONNE Number(10) NOT NULL,
    PERIODE Date,
    MTT Number,
    MOTIF VarChar2(4),
    LIB VarChar2(25),
    DTPAIE Date,
    ESTADO VarChar2(1),
    CONSTRAINT RDB$PRIMARY428 PRIMARY KEY (
      NUMIMP
    )
)
/

CREATE TABLE LOGIC_021.INTERNET (
    NUMABONNE Number(10) NOT NULL,
    SYSTEMEOPE VarChar2(11),
    RACSANAME VarChar2(50),
    EQUIPEMENT VarChar2(20),
    CONTACTO VarChar2(25),
    LOGINCOMMUT VarChar2(25),
    CABLEMODEM VarChar2(15),
    RACSANUMCONTRAT Number(10),
    TIPOCABLEMODEM VarChar2(6),
    USERNAME VarChar2(50),
    FECHAVENCE Date,
    ORDRE Number(10),
    CONSTRAINT RDB$PRIMARY34 PRIMARY KEY (
      NUMABONNE
    )
)
/

CREATE TABLE LOGIC_021.INTERVENANT (
    CODINT VarChar2(4) NOT NULL,
    NOM VarChar2(42),
    ACTIVIDAD VarChar2(3),
    TIPO VarChar2(4),
    CODINSEE VarChar2(3),
    PRIORIDAD Number(10),
    EMAIL VarChar2(50),
    MSGCORTO VarChar2(50),
    CONSTRAINT RDB$PRIMARY19 PRIMARY KEY (
      CODINT
    )
)
/

CREATE TABLE LOGIC_021.INTERVENTION (
    NUMINTER Number(10) NOT NULL,
    NUMABONNE Number(10),
    DTDEB Date,
    DTFIN Date,
    HEURE VarChar2(5),
    OPESAISIE VarChar2(10),
    OPEMODIF VarChar2(10),
    MOTIF VarChar2(4),
    PANNE VarChar2(4),
    REPONSE VarChar2(4),
    SIEGE VarChar2(4),
    INTERVENANT VarChar2(4),
    DETMOTIF VarChar2(50),
    DETPANNE VarChar2(50),
    DETREP VarChar2(50),
    LIB VarChar2(25),
    NUMRDV Number(10),
    LATE VarChar2(4),
    HEUREDEB VarChar2(5),
    HEUREFIN VarChar2(5),
    DTCLOS Date,
    DTEDTOR Date,
    HRCLOS VarChar2(5),
    TRASDEB VarChar2(5),
    TRASFIN VarChar2(5),
    TIPO VarChar2(4),
    DTOTAVERIA Date,
    GRUPOLATE VarChar2(4),
    ESTADO VarChar2(1),
    ROLLINICIAL Date,
    ROLLFINAL Date,
    TIPOINSTAL VarChar2(1),
    FECH_CHG_GRUPO Date,
    HORA_CHG_GRUPO VarChar2(5),
    CONSTRAINT RDB$PRIMARY5 PRIMARY KEY (
      NUMINTER
    )
)
/

/*******************************************************************************
 * Indices
 * -------
 * Extracted at 05/08/2005 03:50:13 p.m.
 ******************************************************************************/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.ABONNEINDEX1
 ON LOGIC_021.ABONNE(NUMCONTRAT)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.ABONNEINDEX2
 ON LOGIC_021.ABONNE(CBOR)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.ABONNEINDEX3
 ON LOGIC_021.ABONNE(LOCALIZATION)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.ABONNEINDEX4
 ON LOGIC_021.ABONNE(NOM)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.ABONNEPPVINDEX1
 ON LOGIC_021.ABONNEPPV(NUMEVENT)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.ABONNEPPVINDEX2
 ON LOGIC_021.ABONNEPPV(NUMABONNE)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.AVERINTERNETINDEX2
 ON LOGIC_021.AVERINTERNET(NUMABONNE)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.AVERINTERNETINDEX3
 ON LOGIC_021.AVERINTERNET(NUMOT)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.AVERINTERNETINDEX4
 ON LOGIC_021.AVERINTERNET(NUMCASO)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.BLOCNOTEINDEX1
 ON LOGIC_021.BLOCNOTE(NUMABONNE)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.CAJAPRINCINDEX1
 ON LOGIC_021.CAJAPRINC(DTCPT)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.CAJAPRINCINDEX2
 ON LOGIC_021.CAJAPRINC(CODOPE)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.CDDTRCONDIINDEX1
 ON LOGIC_021.CDDTRCONDI(FECHA)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.CDDTRCONDIINDEX2
 ON LOGIC_021.CDDTRCONDI(TELEFONO)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.CDDTRCONDIINDEX3
 ON LOGIC_021.CDDTRCONDI(NUMABONNE)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.CONTRATINDEX1
 ON LOGIC_021.CONTRAT(DTRESI)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.CONTRATINDEX2
 ON LOGIC_021.CONTRAT(CODVDS)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.CORREOSINDEX1
 ON LOGIC_021.CORREOS(NUMINTER)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.CORREOSINDEX2
 ON LOGIC_021.CORREOS(ORDRE)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.DECOLUNESINDEX1
 ON LOGIC_021.DECOLUNES(JOUR)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.DETECINDEX1
 ON LOGIC_021.DETEC(NUMPIECE)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.DETECINDEX2
 ON LOGIC_021.DETEC(CODPROD)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.DETINTERINDEX1
 ON LOGIC_021.DETINTER(NUMINTER)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.DETINTERINDEX2
 ON LOGIC_021.DETINTER(CODPROD)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.ECRITCPTINDEX1
 ON LOGIC_021.ECRITCPT(DTSAISIE)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.ECRITCPTINDEX2
 ON LOGIC_021.ECRITCPT(NUMABONNE)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.ECRITCPTINDEX3
 ON LOGIC_021.ECRITCPT(RESUMANU)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.ECRITCPTINDEX4
 ON LOGIC_021.ECRITCPT(PERIODE)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.ECRITCPTINDEX5
 ON LOGIC_021.ECRITCPT(MOTIFIMP)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.HISTERMINALINDEX1
 ON LOGIC_021.HISTERMINAL(NUMABONNE)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.HISTERMINALINDEX2
 ON LOGIC_021.HISTERMINAL(NUMSERIE)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.IMPAYEINDEX1
 ON LOGIC_021.IMPAYE(NUMABONNE)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.INTERVENTIONINDEX1
 ON LOGIC_021.INTERVENTION(DTDEB)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.INTERVENTIONINDEX2
 ON LOGIC_021.INTERVENTION(NUMABONNE)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.INTERVENTIONINDEX3
 ON LOGIC_021.INTERVENTION(DTCLOS)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.OALIASNAME
 ON LOGIC_021.DICO(TYPEID, ALIASNAME)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE UNIQUE INDEX LOGIC_021.OBJID
 ON LOGIC_021.DICO(OBJID, VERSION)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.ONAME
 ON LOGIC_021.DICO(TYPEID, "NAME")
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.RDB$FOREIGN210
 ON LOGIC_021.BITACORA_NODOS(ESTADO)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.RDB$FOREIGN211
 ON LOGIC_021.BITACORA_NODOS(CODIGO_HEADEND, CODIGO_HUB, NUMNODE)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE UNIQUE INDEX LOGIC_021.RDB$PRIMARY2
 ON LOGIC_021.CIUDADES(CODIGO)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE UNIQUE INDEX LOGIC_021.RDB$PRIMARY56
 ON LOGIC_021.CANTONES(CPROV, CCANTON)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE UNIQUE INDEX LOGIC_021.RDB$PRIMARY57
 ON LOGIC_021.DISTRITOS(CPROV, CCANTON, CDISTRI)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.RELDEST
 ON LOGIC_021.DICO(DESTOBJID, DESTVERSION, TYPEID, SRCOBJID, SRCVERSION)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.RELSRC
 ON LOGIC_021.DICO(SRCOBJID, SRCVERSION, TYPEID, DESTOBJID, DESTVERSION)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE INDEX LOGIC_021.TYPEID
 ON LOGIC_021.DICO(TYPEID)
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE (
    INITIAL         64K
    MINEXTENTS      1
    MAXEXTENTS      2147483645
 )
 LOGGING
 TABLESPACE DATOS
/

/*******************************************************************************
 * Views
 * -----
 * Extracted at 05/08/2005 03:50:13 p.m.
 ******************************************************************************/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE VIEW LOGIC_021.AVERIASINDETINTER (NUMINTER, NUMABONNE, DTDEB, TIPO, LIB, MOTIF, CODPROD, MOVIMIENTO)
AS
select numinter, numabonne, dtdeb, tipo, lib, motif, '0000' as codprod, 'Add' as movimiento
      from intervention
       where
        estado = 'F' and intervention.tipo = 'Apl'
/

/*******************************************************************************
 * Triggers
 * --------
 * Extracted at 05/08/2005 03:50:13 p.m.
 ******************************************************************************/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE TRIGGER LOGIC_021.DETALLE_SOLICITUD_CP_ID
 BEFORE INSERT
 ON DETALLE_SOLICITUD_CP
 FOR EACH ROW
begin
  if (:new.ID_DETALLE is null) then
      SELECT DETALLE_SOLICITUD_CP_GEN.NEXTVAL
         INTO :new.ID_DETALLE
      FROM DUAL;
  END IF;
end;
/

/*******************************************************************************
 * Stored Procedures
 * -----------------
 * Extracted at 05/08/2005 03:50:13 p.m.
 ******************************************************************************/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE COSTO_INSTALACION (CP IN VARCHAR2, COSTO OUT NUMBER) IS
   copr  varchar2(4);
   monto number;
BEGIN
   select CTINST into copr
   from produit
   where codprod = cp;

   select prix into monto
   from produit
   where codprod = copr;

   costo := greatest(monto,0);

END;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE COSTO_INSTALACION_MODIF (CP VARCHAR2, COSTO OUT NUMBER) IS
   copr  varchar2(4);
   monto number;
BEGIN
   select CTMODIF  into copr
   from produit
   where codprod = cp;

   select prix  into monto
   from produit
   where codprod = copr;

   costo:=Greatest(monto, 0);

   --FOR select CTMODIF from produit where codprod =:cp into :copr do
   --begin
   -- select prix from produit where codprod =:copr into monto;
   -- if (monto > 0 ) then
   --    costo = monto;
   -- else
   --     costo = 0;
   -- end
END;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INC_PAGO(NUMPAGO OUT NUMBER) IS
begin
   Select INCPAGO.nextval into NUMPAGO
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INC_SAL_PEND(NUM_SALDO_PENDIENTE OUT NUMBER) IS
BEGIN
   Select INC_SALDOS_PENDIENTES.nextval into NUM_SALDO_PENDIENTE
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCABONNE(NUMABONNE OUT NUMBER) IS
begin
   Select IncNumAbonne.nextval into NumAbonne
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCAPPEL(NUMAPPEL OUT NUMBER) IS
begin
   Select IncNumAppel.nextval into NumAppel
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCBN(NUMBN OUT NUMBER) IS
begin
   Select IncNumBN.nextval into NumBN
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCBNINT(NUMBNINT OUT NUMBER) IS
begin
   Select IncNumBNINT.nextval into NumBNInt
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCCAMBIO(NUMCAMBIO OUT NUMBER) IS
begin
   Select IncNumCAMBIO.nextval into NumCAMBIO
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCEC(NUMEC OUT NUMBER) IS
begin
   Select IncNumEC.nextval into NumEC
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCHIST(NUMHIST  OUT NUMBER) IS
begin
   Select IncNumHist.nextval into NumHist
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCIMP(NUMIMP OUT NUMBER) IS
begin
   Select IncNumImp.nextval into Numimp
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCITV(NUMITV OUT NUMBER) IS
begin
   Select IncNumITV.nextval into NumITV
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCLOGIN(NUMLOGIN OUT NUMBER) IS
begin
   Select INCNUMLOGIN.nextval into NUMLOGIN
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCLOGRELOJ(ID OUT NUMBER) IS
begin
   Select INCLOGRELOJX.nextval into ID
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCMAIL(NUMMAIL OUT NUMBER) IS
begin
   Select INCNUMMAIL.nextval into NUMMAIL
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCMOUVEMENT(NUMMOUVEMENT OUT NUMBER) IS
begin
   Select IncNumMouvement.nextval into NumMouvement
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCNUMIP(NUMIP OUT NUMBER) IS
begin
   Select INCIP.nextval into NumIP
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCNUMLOTE(NUMLOTE OUT NUMBER) IS
begin
   Select IncNumLoteX.nextval into NumLote
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCORDREPPV(NUMORDREPPV OUT NUMBER) IS
begin
   Select IncNumordrePPV.nextval into NumOrdrePPV
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCPAYAV(NUMPIECE OUT NUMBER) IS
begin
   Select IncNumPAYAV.nextval into NumPIECE
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCRDV(NUMRDV OUT NUMBER) IS
begin
   Select IncNumRDV.nextval into NumRDV
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCRECH(NUMRECH OUT NUMBER) IS
begin
   Select IncNumrech .nextval into Numrech
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCRECU(NUMRECU OUT NUMBER) IS
begin
   Select IncNumRecu.nextval into NumRecu
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCROLE(NUMROLE OUT NUMBER) IS
begin
   Select IncNumROLE.nextval into NumROLE
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCSOC(NUMSOC OUT NUMBER) IS
begin
   Select IncNumSoc.nextval into NumSoc
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCSTATRECO(NUMSTATRECO OUT NUMBER) IS
begin
   Select IncNumSTATRECO.nextval into NumSTATRECO
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCTRANSACDLA(NUMTRANSACDLA OUT NUMBER) IS
begin
   Select IncTransacDLAX.nextval into NumTransacDLA
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCVENTE(NUMVENTE OUT NUMBER) IS
begin
   Select IncNumVente.nextval into NumVente
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INCVISITE(NUMVISITE OUT NUMBER) IS
begin
   Select IncNumVisite.nextval into NumVisite
   from dual;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_BLOC_NOTE(NUMABONNE NUMBER, LIB VARCHAR2, DTSAISIE DATE, CODOPE VARCHAR2) IS
   Vnumbn number;
begin
   incbn(Vnumbn);

   insert into Blocnote
     (numBN, numabonne,lib, dtsaisie,codope)
   values
     (Vnumbn, numabonne, lib, dtsaisie,codope);
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_BN_INTERNET(NUMLLAMADA NUMBER,
   NUMABONNE NUMBER,
   FECHAINI DATE,
   HORAINI VARCHAR2,
   USUARIOINI VARCHAR2,
   MOTIVO VARCHAR2,
   RESPUESTA VARCHAR2,
   OBSERVACION VARCHAR2, --xxx 4096
   ESTADO CHAR,
   GRUPOLATE VARCHAR2,
   NUMBINT OUT NUMBER) IS
  numbnint NUMBER;
begin
   incbnint(numbnint);

   insert into Averinternet
      (numllamada, numabonne, fechaini, horaini, usuarioini,
       motivo,respuesta,observacion,estado,grupolate)
   values
      (numbnint, numabonne,fechaini,horaini,usuarioini,motivo,respuesta,observacion,estado,grupolate);

   numbint :=numbnint;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_BN_INTERNETB (NUMLLAMADA NUMBER,
  NUMABONNE NUMBER,
  FECHAINI DATE,
  HORAINI VARCHAR2,
  USUARIOINI VARCHAR2,
  MOTIVO VARCHAR2,
  RESPUESTA VARCHAR2,
  OBSERVACION VARCHAR2, -- xxx 4096
  ESTADO CHAR,
  GRUPOLATE VARCHAR2,
  PRIORIDAD NUMBER,
  NUMBINT OUT NUMBER) IS
  numbnint NUMBER;
begin
   incbnint(numbnint);
   insert into Averinternet
      (numllamada, numabonne, fechaini, horaini, usuarioini, motivo,respuesta,observacion,estado,grupolate,prioridad)
   values
    (numbnint,numabonne,fechaini,horaini,usuarioini,motivo,respuesta,observacion,estado,grupolate,prioridad);
   numbint := numbnint;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_COLILLA (NUMABONNE NUMBER,
  NUMSOUSCRIPT NUMBER,
  NOM VARCHAR2,
  DTSAISIE DATE,
  CODOPE VARCHAR2)  IS
   numcambio integer;

begin
   inccambio(numcambio);

   insert into CAMBIOCOLILLA
      (numcambio, numabonne, numsouscript, nom, dtsaisie, codope)
   values
     (numcambio, numabonne, numsouscript, nom, dtsaisie, codope);
END;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_DETEC_CHQ (
  NUMPIECE NUMBER,
  NUMCHQ CHAR,
  BANKCHQ CHAR)  IS
BEGIN
   insert into DETECHQ
     (numpiece, numchq, bankchq)
   values
     (numpiece, numchq, bankchq);

END;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_DETEC_F_A (
  NUMPIECE NUMBER,
  CODPROD CHAR, -- xxx realmente es fijo?
  CODTVA CHAR,
  JRNLDET CHAR,
  MTT NUMBER) IS -- xxx MTT DOUBLE
BEGIN
   insert into DETEC
     (numpiece, codprod, mtt, codtva, numjrnl)
   values
     (numpiece, codprod, mtt, codtva, jrnldet);
END;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_DETINTER (
  NUMINTER NUMBER,
  CODPROD CHAR,
  QTEDMD NUMBER, --xxx era SMALLINT
  ORDREVTE NUMBER,
  MOVIMIENTO CHAR,
  ESTADO CHAR)  IS
BEGIN
   insert into DETINTER
      (numinter, codprod, qtedmd, ordrevte, movimiento, estado)
   values
      (numinter, codprod, qtedmd, ordrevte, movimiento, estado);
END;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_ECRITCPT_DETEC_F_A (
  NUMABONNE NUMBER,
  PERIODE CHAR,
  DTCPT  DATE,
  DTSAISIE  DATE,
  LIB VARCHAR2,
  MTTDEB DOUBLE PRECISION,
  MTTCRED DOUBLE PRECISION,
  CODOPE VARCHAR2,
  MDRGLT CHAR,
  CODINSEE CHAR,
  NUMJRNL CHAR,
  RECONCIL CHAR,
  MOTIFIMP CHAR,
  TYPEC CHAR,
  CBOR CHAR,
  RESUMANU NUMBER,
  CODPROD CHAR,
  CODTVA CHAR,
  JRNLDET CHAR,
  NUMFACT OUT NUMBER) IS
  numEC NUMBER;
  encaisse     number;
  reste        number;
  mtt          number;


begin
   incEC(numEC);

   encaisse := 0;
   if mttdeb = 0 then
      mtt:=mttcred;
   end if;
   if mttcred =0 then
      mtt:=mttdeb;
   end if;
   if typec ='FAC' then
      reste :=mttdeb;
   elsif typec ='AVR' then
      reste := mttCRED;
   end if;

   insert into ECRITCPT
       (numpiece, numabonne, periode, dtcpt,  dtsaisie,  numjrnl,  lib,  numfact,  mttdeb,
        mttcred, mdrglt, reconcil, motifimp, codope, encaisse, reste, codinsee,
        typec, cbor, resumanu)
   values
      (numEC, numabonne, periode, dtcpt, dtsaisie, numjrnl, lib, numEC, mttdeb,
       mttcred, mdrglt, reconcil, motifimp, codope, encaisse, reste, codinsee,
       typec, cbor, resumanu);



   insert into DETEC
      (numpiece,codprod, mtt, codtva, numjrnl)
   values
      (numEC, codprod, mtt, codtva, jrnldet);

   numfact := numec;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_ECRITCPT_F_A (NUMABONNE NUMBER,
  PERIODE CHAR,
  DTCPT  DATE,
  DTSAISIE  DATE,
  LIB VARCHAR2,
  MTTDEB DOUBLE PRECISION,
  MTTCRED DOUBLE PRECISION,
  CODOPE VARCHAR2,
  MDRGLT CHAR,
  CODINSEE CHAR,
  NUMJRNL CHAR,
  RECONCIL CHAR,
  MOTIFIMP CHAR,
  TYPEC CHAR,
  CBOR CHAR,
  RESUMANU NUMBER,
  NUMFACT OUT NUMBER) IS
   numEC    NUMBER;
   encaisse number;
   reste    number;

begin
   incEC(numEC);

   encaisse := 0;
   if (typec ='FAC') then
     reste :=mttdeb;
   elsif (typec ='AVR') then
     reste := mttCRED;
   end if;

   insert into ECRITCPT
     (numpiece, numabonne, periode, dtcpt,  dtsaisie,  numjrnl,  lib,  numfact,  mttdeb,
      mttcred, mdrglt, reconcil, motifimp, codope, encaisse, reste, codinsee,
      typec, cbor, resumanu)
   values
     (numEC, numabonne, periode, dtcpt, dtsaisie, numjrnl, lib, numEC, mttdeb,
      mttcred, mdrglt, reconcil, motifimp, codope, encaisse, reste, codinsee,
      typec, cbor, resumanu);

   numfact := numec;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_HISTERMINAL (
  NUMABONNE NUMBER,
  NUMSERIE CHAR,
  CODOPE CHAR,
  TIPOMOVIMIENTO CHAR,
  FECHAMOVI  DATE,
  COMMENT VARCHAR2)  IS
   numHIST NUMBER;

begin
   inchist(numhist);

   insert into HISTERMINAL
      (numHIST, numabonne,numserie,fechamovi, codope,tipomovimiento,comment)
   values
      (numHIST, numabonne,numserie,fechamovi,codope,tipomovimiento,comment);
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_IMPAYE (
  NUMABONNE NUMBER,
  NUMPIECE NUMBER,
  MOTIF CHAR,
  LIB CHAR,
  ESTADO CHAR,
  MTT NUMBER, -- xxx DOUBLE PRECISION,
  PERIODE  DATE)  IS
   numimp NUMBER;

begin
   incimp(numimp);

   insert into impaye
     (numimp, numabonne,periode,mtt,motif,estado,numpiece,lib)
   values
     (numimp, numabonne, periode, mtt, motif, estado, numpiece, lib);
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_INTERVENTION (
  NUMABONNE NUMBER,
  NUMRDV NUMBER,
  DTDEB  DATE,
  HEURE CHAR,
  LIB VARCHAR2,
  TIPO CHAR,
  ESTADO CHAR,
  MOTIF CHAR,
  REPONSE CHAR,
  DETMOTIF VARCHAR2,
  DETREP VARCHAR2,
  OPESAISIE VARCHAR2,
  DTOTAVERIA  DATE,
  NUMITV OUT NUMBER) IS
   numinter NUMBER ;
begin
   incItv(numinter);

   insert into Intervention
     (numinter, numabonne,dtdeb, heure, lib, tipo,motif,reponse,
     opesaisie,numrdv,detmotif,detrep, dtotaveria, estado)
   values
     (numinter, numabonne, dtdeb, heure, lib, tipo, motif, reponse,
      opesaisie, numrdv, detmotif, detrep, dtotaveria, estado);
  NUMITV := NUMINTER;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_INTERVENTION2 (
  NUMABONNE NUMBER,
  NUMRDV NUMBER,
  DTDEB  DATE,
  HEURE CHAR,
  LIB VARCHAR2,
  TIPO CHAR,
  ESTADO CHAR,
  MOTIF CHAR,
  REPONSE CHAR,
  DETMOTIF VARCHAR2,
  DETREP VARCHAR2,
  OPESAISIE VARCHAR2,
  DTOTAVERIA  DATE,
  GRUPOLATE VARCHAR2,
  NUMITV OUT NUMBER) IS
   numinter NUMBER ;

begin
   incItv(numinter);

   insert into Intervention
      (numinter, numabonne,dtdeb, heure, lib, tipo,motif,reponse,
      opesaisie,numrdv,detmotif,detrep, dtotaveria, estado, grupolate)
   values
      (numinter, numabonne, dtdeb, heure, lib, tipo, motif, reponse,
       opesaisie, numrdv, detmotif, detrep, dtotaveria, estado, grupolate);
   NUMITV := NUMINTER;
end;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_RECHABONNE (ABONNE NUMBER,
  NOM CHAR,
  TEL CHAR,
  NUMCTRT NUMBER,
  SOUSCRIT NUMBER,
  NUMRECHID OUT NUMBER) IS
   numID NUMBER;

begin
   increch(numid);

   insert into Rechabonne
     (numid, abonne,souscrit,nom, tel,numctrt)
   values
     (numid, abonne, souscrit, nom, tel, numctrt);
   NUMRECHID := NUMID;
End;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_RECUPIMP (NUMABONNE NUMBER,
  MTT NUMBER,
  STATUT CHAR,
  TIPOPAGO CHAR,
  NUMRECU CHAR) IS
begin
   insert into RECUPIMP
      (numabonne,mtt, statut,tipopago,numrecu)
   values
      (numabonne, mtt, statut, tipopago, numrecu);
End;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_RGT_DETEC (NUMPIECE NUMBER,
  CODPROD CHAR,
  CODTVA CHAR,
  JRNLDET CHAR,
  MTT NUMBER)  IS
begin
   insert into DETEC
      (numpiece, codprod, mtt, codtva, numjrnl)
   values
      (numpiece, codprod, mtt, codtva, jrnldet);
End;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_RGT_DIRECT (NUMABONNE NUMBER,
  PERIODE CHAR,
  DTCPT  DATE,
  DTSAISIE  DATE,
  NUMJRNL CHAR,
  LIB VARCHAR2,
  NUMFACT NUMBER,
  MTTDEB DOUBLE PRECISION,
  MTTCRED DOUBLE PRECISION,
  MDRGLT CHAR,
  CODOPE VARCHAR2,
  CODINSEE CHAR,
  TYPEC CHAR,
  CBOR CHAR,
  RESUMANU NUMBER,
  NUMLOTE VARCHAR2,
  NUMRGT OUT NUMBER) IS
   numpiece NUMBER;
begin
   incEC(numpiece);

   insert into ecritcpt
      (numpiece, numabonne, periode, dtcpt,  dtsaisie,  numjrnl,  lib,  numfact,  mttdeb,
       mttcred, mdrglt, reconcil, motifimp,codope, encaisse, reste, codinsee, typec, cbor, resumanu,
       numlote)
   values
      (numpiece, numabonne, periode, dtcpt, dtsaisie, numjrnl, lib, numfact, mttdeb,
       mttcred, mdrglt, 'F', '', codope, mttcred,0, codinsee, typec, cbor, resumanu,
       numlote);
   numrgt := numpiece;
End;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_RGT_FROM_TEMPEC (
  NUMPIECE NUMBER,
  NUMABONNE NUMBER,
  PERIODE CHAR,
  DTCPT  DATE,
  DTSAISIE  DATE,
  NUMJRNL CHAR,
  LIB VARCHAR2,
  NUMFACT NUMBER,
  MTTDEB NUMBER,
  MTTCRED NUMBER,
  MDRGLT CHAR,
  CODOPE VARCHAR2,
  CODINSEE CHAR,
  TYPEC CHAR,
  CBOR CHAR,
  RESUMANU NUMBER,
  NUMLOTE VARCHAR2,
  MOTIFIMP CHAR)  IS
begin
   insert into ecritcpt
     (numpiece, numabonne, periode, dtcpt,  dtsaisie,  numjrnl,  lib,  numfact,  mttdeb,
      mttcred, mdrglt, reconcil, motifimp,codope, encaisse, reste, codinsee, typec, cbor,
      resumanu, numlote)
   values
     (numpiece, numabonne, periode, dtcpt, dtsaisie, numjrnl, lib, numfact, mttdeb,
      mttcred, mdrglt, 'F', motifimp, codope, mttcred,0, codinsee, typec, cbor, resumanu,
      numlote);
End;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_ROL (
  NUMINTER NUMBER,
  TIPO CHAR,
  DTSAISIE  DATE,
  HRSAISIE CHAR,
  OPESAISIE VARCHAR2,
  FECHACITA  DATE,
  HRCITA CHAR,
  OBSERVACION VARCHAR2,
  STATUS CHAR,
  CODINT CHAR,
  MOVIL CHAR,
  SECTOR CHAR,
  PADRINO VARCHAR2)  IS
   numrole NUMBER ;

begin
   incRole(numrole);

   insert into roles
      (numrole, numinter, tipo,dtsaisie, hrsaisie, opesaisie, fechacita,hrcita,
       observacion,status, codint, movil, sector, padrino)
   values
      (numrole,numinter, tipo,dtsaisie, hrsaisie, opesaisie, fechacita,hrcita,
      observacion,status, codint, movil, sector, padrino);
End;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_STAT_RECO (
  NUMABONNE NUMBER,
  DTRECO  DATE,
  DTRESI  DATE)  IS
   numstatreco NUMBER;

begin
   incstatreco(numstatreco);

   insert into StatRECO
      (numstatreco, numabonne,dtreco,dtresi)
   values
      (numstatreco, numabonne,dtreco,dtresi);
End;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_TEMPDETEC (
  NUMTEMP NUMBER,
  CODPROD CHAR,
  CODTVA CHAR,
  JRNLDET CHAR,
  MTT NUMBER)  IS
begin
   insert into TEMPDETEC
      (numtemp, codprod, mtt, codtva, numjrnl)
   values
      (numtemp, codprod, mtt, codtva, jrnldet);
End;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_TEMPEC (
  NUMABONNE NUMBER,
  PERIODE CHAR,
  DTCPT  DATE,
  DTSAISIE  DATE,
  NUMJRNL CHAR,
  LIB VARCHAR2,
  NUMFACT NUMBER,
  MTTDEB NUMBER,
  MTTCRED NUMBER,
  MDRGLT CHAR,
  CODOPE VARCHAR2,
  CODINSEE CHAR,
  TYPEC CHAR,
  CBOR CHAR,
  RESUMANU NUMBER,
  NUMLOTE VARCHAR2,
  MOTIFIMP CHAR,
  LIBNC VARCHAR2,
  NUMCHQ CHAR,
  BANKCHQ CHAR,
  NUMRGT OUT NUMBER) IS
   numEC NUMBER;
begin
   incEC(numEC);

   insert into TEMPEC
      (numtemp, numabonne, periode, dtcpt,  dtsaisie,  numjrnl,  lib,  numfact,  mttdeb,
       mttcred, mdrglt, codope, codinsee, typec, cbor, resumanu, numlote , motifimp, libnc,
       numchq, bankchq)
   values
      (numEC, numabonne, periode, dtcpt, dtsaisie, numjrnl, lib, numfact, mttdeb,
       mttcred, mdrglt, codope, codinsee, typec, cbor, resumanu, numlote, motifimp,
       libnc,numchq, bankchq);
   numrgt := numec;
End;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_TEMPEC_TEMPDETEC (
  NUMABONNE NUMBER,
  PERIODE CHAR,
  DTCPT  DATE,
  DTSAISIE  DATE,
  NUMJRNL CHAR,
  LIB VARCHAR2,
  NUMFACT NUMBER,
  MTTDEB NUMBER,
  MTTCRED NUMBER,
  MDRGLT CHAR,
  CODOPE VARCHAR2,
  CODINSEE CHAR,
  TYPEC CHAR,
  CBOR CHAR,
  RESUMANU NUMBER,
  CODPROD CHAR,
  CODTVA CHAR,
  JRNLDET CHAR,
  NUMLOTE VARCHAR2,
  MOTIFIMP CHAR,
  LIBNC VARCHAR2,
  NUMCHQ CHAR,
  BANKCHQ CHAR,
  NUMRGT OUT NUMBER) IS
   numEC NUMBER;
   mtt number;
begin
   incEC(numEC);

   if mttdeb = 0 then
      mtt:=mttcred;
   end if;
   if mttcred =0 then
      mtt:=mttdeb;
   end if;
   insert into TEMPEC
      (numtemp, numabonne, periode, dtcpt,  dtsaisie,  numjrnl,  lib,  numfact,  mttdeb,
       mttcred, mdrglt, codope, codinsee, typec, cbor, resumanu, numlote , motifimp, libnc,
       numchq, bankchq)
   values
      (numEC, numabonne, periode, dtcpt, dtsaisie, numjrnl, lib, numfact, mttdeb,
       mttcred, mdrglt, codope, codinsee, typec, cbor, resumanu, numlote , motifimp,
       libnc,numchq, bankchq);
   insert into TEMPDETEC
      (numtemp, codprod, mtt, codtva, numjrnl)
   values
      (numEC, codprod, mtt, codtva, jrnldet);

   numrgt := numec;
End;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_TRANSACDLA (
  DTSAISIE  DATE,
  HEURETRANSAC CHAR,
  OPETRANSAC CHAR,
  ENVOITRANSAC CHAR,
  NUMTRANSAC OUT NUMBER) IS
   numtransacdla NUMBER;

begin
   INCTRANSACDLA(numtransacdla);
   insert into TRANSACDLA
      (numtransacdla, dtsaisie,heureTransac,envoitransac,opetransac)
   values
      (numtransacdla, dtsaisie,heureTransac,envoitransac,opetransac);
   NUMTRANSAC := NUMTRANSACDLA;
End;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE INSERT_VENTE (
  NUMABONNE NUMBER,
  CODPROD CHAR,
  DTSAISIE  DATE,
  DTSIGN  DATE,
  MTT NUMBER,
  MTTDOL NUMBER,
  CODPROV CHAR,
  CODVEND CHAR,
  CTINST NUMBER,
  CTREDUC NUMBER,
  QTEDMD NUMBER, -- xxx SMALLINT
  STATUT CHAR,
  ORDREVTE OUT NUMBER) IS
   numordre NUMBER;

begin
   incvente(numordre);

   insert into Vente
      (ordre, numabonne,codprod, dtsaisie, dtsign, mtt, mttdol, codprov, codvend,
      ctinst, ctreduc,qtedmd,statut)
   values
      (numordre, numabonne, codprod, dtsaisie, dtsign, mtt, mttdol, codprov,
       codvend, ctinst, ctreduc,qtedmd, statut);
   ORDREVTE := NUMORDRE;
End;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE MAJ_ABONNE_MOINS (NUMABONNE NUMBER,
   MONTANT NUMBER)  IS
   pNumAb  number(10):=NumAbonne;
begin
   UPDATE ABONNE
      SET SOLDE = SOLDE - montant
   WHERE NUMABONNE = pNumAb;
   UPDATE AG
      set sold1 = sold1 - montant,
          sold5 = sold5 - montant
   where NUMABONNE = pNumAb;
End;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE MAJ_ABONNE_PLUS (NUMABONNE NUMBER,
  MONTANT NUMBER)  IS
   pNumAb  number(10):=NumAbonne;
begin
   UPDATE ABONNE
      SET SOLDE = SOLDE + montant
   WHERE NUMABONNE = pNUMAB;

   UPDATE AG
      set sold1 = sold1 + montant,
          sold5 = sold5 + montant
   where NUMABONNE = pNumAb;
End;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE MAJ_AG (NUMABONNE NUMBER,
  MONTANT NUMBER)  IS
   pNumAb  number(10):=NumAbonne;
begin
   UPDATE AG
      SET SOLD1 = SOLD1 + montant,
          sold5 = sold5 + montant
   WHERE NUMABONNE = pNumAb;
End;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE MAJ_DET_FACTURE (
  NUMPIECE NUMBER,
  MONTANT NUMBER,
  CODPROD CHAR)  IS
   pNumPiece number(10):=NUMPIECE;
   pCodProd varchar2(4):=CODPROD;
begin
   update detec
      Set mtt = mtt + montant
   where numpiece = pnumpiece
     and codprod = pcodprod;
End;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE MAJ_FACTURE (
  NUMABONNE NUMBER,
  MONTANT NUMBER,
  PERIODE CHAR)  IS
   pNumAb    number(10):=NumAbonne;
   pPeriode  varchar2(7):=Periode;
begin
   update ecritcpt
     set mttdeb = mttdeb + montant
  where numabonne = pNumAb
    and periode = pPeriode
    and codope='AUTO';
End;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE MAJ_SOLDE_ABONNE (NUMABONNE NUMBER,
  MONTANT NUMBER)  IS
   pNumAb    number(10):=NumAbonne;
begin
   UPDATE ABONNE
      SET SOLDE = montant
   WHERE NUMABONNE = pNumAb;
End;
/

ALTER SESSION SET CURRENT_SCHEMA = LOGIC_021
/

CREATE OR REPLACE PROCEDURE MAJ_TOT_AG (
  NUMABONNE NUMBER,
  MTTSOLD1 NUMBER,
  MTTSOLD2 NUMBER,
  MTTSOLD3 NUMBER,
  MTTSOLD4 NUMBER,
  MTTSOLD5 NUMBER)  IS
   pNumAb    number(10):=NumAbonne;
begin
   UPDATE AG
      SET SOLD1 = MTTSOLD1,
          SOLD2 = MTTSOLD2,
          SOLD3 = MTTSOLD3,
          SOLD4 = MTTSOLD4,
          sold5 = MTTSOLD5
   WHERE NUMABONNE = pNumAb;
End;
/
