--------------------------------------------------------------------------
-- Play this script in PRUEBAS@VISANY to make it look like DESA@VISMAR
--                                                                      --
-- Please review the script before using it to make sure it won't       --
-- cause any unacceptable data loss.                                    --
--                                                                      --
-- PRUEBAS@VISANY Schema Extracted by User PRUEBAS 
-- DESA@VISMAR Schema Extracted by User DESA 

ALTER TABLE RELLECTURAS
 DROP CONSTRAINT RELMAESTROLECTURAS_FK;

ALTER TABLE RELMAESTRO
 DROP CONSTRAINT RELPARAMETROS_MAESTRO_FK;

ALTER TABLE RELMARCAS
 DROP CONSTRAINT RELMAESTRO_MARCAS_FK;

ALTER TABLE VENFACTMP
 DROP PRIMARY KEY CASCADE;

ALTER TABLE COM_CARGOS_NACIONALIZACION
 DROP CONSTRAINT COMENCNACIONALIZA_CARNAC_FK;

ALTER TABLE PENSIONADO
 DROP PRIMARY KEY CASCADE;
DROP TABLE PENSIONADO CASCADE CONSTRAINTS;

--
-- ARTICULOSVTMP  (Table) 
--
CREATE TABLE ARTICULOSVTMP
(
  COD_CIA         CHAR(3 BYTE)                  NOT NULL,
  COD_BODEGA      CHAR(3 BYTE)                  NOT NULL,
  COD_ARTICULO    VARCHAR2(25 BYTE)             NOT NULL,
  DES_ARTICULO    VARCHAR2(50 BYTE)             NOT NULL,
  CAN_EXISTE      NUMBER(14,4)                  NOT NULL,
  COSTO           NUMBER(14,4)                  NOT NULL,
  FEC_ULT_COMPRA  DATE,
  CAN_ULT_COMPRA  NUMBER(14,4),
  FEC_PEN_COMPRA  DATE,
  CAN_PEN_COMPRA  NUMBER(14,4),
  CAN_VENTA       NUMBER(14,4),
  COD_PROVEEDOR   VARCHAR2(25 BYTE)
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

ALTER TABLE ARTICULOSVTMP
 ADD CONSTRAINT ARTICULOSVTMP_PK
 PRIMARY KEY
 (COD_CIA, COD_BODEGA, COD_ARTICULO);

-- Difference : Column Order (No action taken) 

--
-- COLISIONES  (Table) 
--
CREATE TABLE COLISIONES
(
  CONCEPTO  VARCHAR2(15 BYTE)                   NOT NULL
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

ALTER TABLE INV_ENCMOVDESP
MODIFY(NUM_DOCTO VARCHAR2(10 BYTE));

ALTER TABLE INV_ENCMOVDESP
MODIFY(NUM_DESPACHO VARCHAR2(10 BYTE));

ALTER TABLE INV_ENCSOLTRASLADO
MODIFY(NUM_DOCTO VARCHAR2(10 BYTE));

ALTER TABLE INV_ENCSOLTRASLADO
MODIFY(NUM_DOCTOSAL VARCHAR2(10 BYTE));

ALTER TABLE INV_MOVGRUPO
MODIFY(NUM_DOCTO VARCHAR2(10 BYTE));

ALTER TABLE INV_MOVGRUPO
MODIFY(NUM_DOCTOGRP VARCHAR2(10 BYTE));

-- Difference : Column Order (No action taken) 

ALTER TABLE INV_TOMAFIS
MODIFY(USUARIO  DEFAULT USER);

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

--
-- PLAN_TABLE  (Table) 
--
CREATE TABLE PLAN_TABLE
(
  STATEMENT_ID     VARCHAR2(30 BYTE),
  TIMESTAMP        DATE,
  REMARKS          VARCHAR2(80 BYTE),
  OPERATION        VARCHAR2(30 BYTE),
  OPTIONS          VARCHAR2(30 BYTE),
  OBJECT_NODE      VARCHAR2(128 BYTE),
  OBJECT_OWNER     VARCHAR2(30 BYTE),
  OBJECT_NAME      VARCHAR2(30 BYTE),
  OBJECT_INSTANCE  NUMBER,
  OBJECT_TYPE      VARCHAR2(30 BYTE),
  OPTIMIZER        VARCHAR2(255 BYTE),
  SEARCH_COLUMNS   NUMBER,
  ID               NUMBER,
  PARENT_ID        NUMBER,
  POSITION         NUMBER,
  COST             NUMBER,
  CARDINALITY      NUMBER,
  BYTES            NUMBER,
  OTHER_TAG        VARCHAR2(255 BYTE),
  PARTITION_START  VARCHAR2(255 BYTE),
  PARTITION_STOP   VARCHAR2(255 BYTE),
  PARTITION_ID     NUMBER,
  OTHER            LONG,
  DISTRIBUTION     VARCHAR2(30 BYTE)
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

ALTER TABLE PREPARAMETRO
MODIFY(MONEDA_PRINCIPAL  DEFAULT 'CL');

ALTER TABLE PREPARMONEDA
MODIFY(COMPREDONDEO NUMBER(5,2));

ALTER TABLE PREPARMONEDA
MODIFY(MULTREDONDEO NUMBER(5,2));

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

--
-- SODCAFE  (Table) 
--
CREATE TABLE SODCAFE
(
  CIA       CHAR(3 BYTE)                        NOT NULL,
  EMPLEADO  VARCHAR2(15 BYTE)                   NOT NULL,
  ENTRADA   DATE                                NOT NULL,
  SALIDA    DATE
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

ALTER TABLE SODCAFE
 ADD CONSTRAINT SODCAFE_PK
 PRIMARY KEY
 (CIA, EMPLEADO, ENTRADA);

--
-- VBCATEGORIA  (Table) 
--
CREATE TABLE VBCATEGORIA
(
  CIA          CHAR(3 BYTE)                     NOT NULL,
  BODEGA       CHAR(3 BYTE)                     NOT NULL,
  CATEGORIA    CHAR(1 BYTE)                     NOT NULL,
  DESCRIPCION  VARCHAR2(30 BYTE)                NOT NULL,
  LOTE         VARCHAR2(15 BYTE)                NOT NULL,
  DESCUENTO    NUMBER(5,2)                      NOT NULL
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

ALTER TABLE VBCATEGORIA
 ADD CONSTRAINT VBCATEGORIA_PK
 PRIMARY KEY
 (CIA, BODEGA, CATEGORIA);

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

ALTER TABLE VENEMPLEADO
MODIFY(USUARIO  DEFAULT user);

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

ALTER TABLE COM_HIST_DETNAC
MODIFY(COD_ARTICULO_FINAL  DEFAULT 'x');

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

ALTER TABLE INV_DETSOLTRASLADO
MODIFY(NUM_DOCTO VARCHAR2(10 BYTE));

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

ALTER TABLE PLAPARAMETRO
 ADD (DIASAGUINALDO  NUMBER(3)                      DEFAULT 15                    NOT NULL);

ALTER TABLE PLAPARAMETRO
 ADD (PORCSUBSIDIO  NUMBER(5,2)                     DEFAULT 100                   NOT NULL);

ALTER TABLE PLAPARAMETRO
 ADD (MOVIMSS  CHAR(3 BYTE));

ALTER TABLE PLAPARAMETRO
 ADD (MOVIMPSAL  CHAR(3 BYTE));

ALTER TABLE PLAPARAMETRO
 ADD (MOVIMPNOMINA  CHAR(3 BYTE));

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

ALTER TABLE COM_ENC_RECLAMO
MODIFY(COD_MOVTO VARCHAR2(3 BYTE));

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

ALTER TABLE GEN_CAMB_PRECIO
MODIFY(COD_MONEDA  DEFAULT 'CL');

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

ALTER TABLE PLAEMPLEADO
MODIFY(MONEDASALARIO  DEFAULT 'CL');

ALTER TABLE PLAEMPLEADO
 ADD (CURP  VARCHAR2(20 BYTE));

-- Difference : Column Order (No action taken) 

--
-- PLAIMPSAL  (Table) 
--
CREATE TABLE PLAIMPSAL
(
  CIA            CHAR(3 BYTE)                   NOT NULL,
  PLANILLA       CHAR(2 BYTE)                   NOT NULL,
  LIMITEINF      NUMBER(14,2)                   NOT NULL,
  CUOTAFIJA      NUMBER(14,2)                   NOT NULL,
  PORCEXCEDENTE  NUMBER(5,2)                    NOT NULL
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

ALTER TABLE PLAIMPSAL
 ADD CONSTRAINT PLAIMPSAL_PK
 PRIMARY KEY
 (CIA, PLANILLA, LIMITEINF);

--
-- PLAIMPSALCREDITO  (Table) 
--
CREATE TABLE PLAIMPSALCREDITO
(
  CIA        CHAR(3 BYTE)                       NOT NULL,
  PLANILLA   CHAR(2 BYTE)                       NOT NULL,
  LIMITEINF  NUMBER(14,2)                       NOT NULL,
  CREDITO    NUMBER(14,2)                       NOT NULL
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

ALTER TABLE PLAIMPSALCREDITO
 ADD CONSTRAINT PLAIMPSALCREDITO_PK
 PRIMARY KEY
 (CIA, PLANILLA, LIMITEINF);

--
-- PLAIMPSALSUBSIDIO  (Table) 
--
CREATE TABLE PLAIMPSALSUBSIDIO
(
  CIA            CHAR(3 BYTE)                   NOT NULL,
  PLANILLA       CHAR(2 BYTE)                   NOT NULL,
  LIMITEINF      NUMBER(14,2)                   NOT NULL,
  CUOTAFIJA      NUMBER(14,2)                   NOT NULL,
  PORCEXCEDENTE  NUMBER(5,2)                    NOT NULL
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

ALTER TABLE PLAIMPSALSUBSIDIO
 ADD CONSTRAINT PLAIMPSALSUBSIDIO_PK
 PRIMARY KEY
 (CIA, PLANILLA, LIMITEINF);

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

--
-- PRYLABORCOBRABLEACTDET  (Trigger) 
--
CREATE OR REPLACE TRIGGER PRYLABORCOBRABLEACTDET
Before Insert or Update Of Proyecto, Tarea, Horas or Delete On PRYLABORCOBRABLE
For Each Row
Declare
   vLabor PryDetalleLabor.Labor%Type;
Begin
   If Inserting Then
      If :New.Control = 'S' Then
         Select Nvl(Max(Labor),0)+1
            Into vLabor
         From PryDetalleLabor
         Where Informe=:New.Informe
           And Fecha  =:New.Fecha;

         Insert Into PryDetalleLabor(Informe, Fecha, Labor, Proyecto, Modulo,
     	  	     	             Referencia, Tarea, HorasPlan, HorasReal,
                                     LaborCobroRef)
            		      Values(:New.Informe, :New.Fecha, vLabor, :New.Proyecto,
                                     Null, Null, :New.Tarea, 0,:New.Horas,
                                     :New.Labor);
      End If;
   Elsif Updating Then
      Update PryDetalleLabor
         Set Proyecto  = :New.Proyecto,
             Tarea     = :New.Tarea,
	     HorasReal = :New.Horas
      Where Informe       = :New.Informe
        And Fecha         = :New.Fecha
        And LaborCobroRef = :New.Labor;
   Else
      Delete From PryDetalleLabor
      Where Informe       = :Old.Informe
        And Fecha         = :Old.Fecha
        And LaborCobroRef = :Old.Labor;
   End If;
End;
/
SHOW ERRORS;

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

ALTER TABLE COM_DET_NACIONALIZACION
MODIFY(COD_ARTICULO_FINAL  DEFAULT 'x');

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

ALTER TABLE GEN_CLIENTE_CLASIF
MODIFY(USUARIO  DEFAULT user);

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

--
-- VENDETRESERVA  (Table) 
--
CREATE TABLE VENDETRESERVA
(
  CIA            CHAR(3 BYTE)                   NOT NULL,
  SUCURSAL       CHAR(3 BYTE)                   NOT NULL,
  DOCUMENTO      NUMBER(10)                     NOT NULL,
  SECUENCIA      NUMBER(4)                      NOT NULL,
  PARTIDA        VARCHAR2(30 BYTE),
  HORA           NUMBER(5,2),
  LLEGADA        VARCHAR2(30 BYTE),
  FECHA          DATE                           NOT NULL,
  GUIA           VARCHAR2(30 BYTE),
  OBSERVACIONES  VARCHAR2(300 BYTE),
  VOUCHER        VARCHAR2(20 BYTE),
  CHOFER         VARCHAR2(30 BYTE),
  MOVIL1         VARCHAR2(30 BYTE),
  MOVIL2         VARCHAR2(30 BYTE),
  ESTADO         CHAR(1 BYTE)                   NOT NULL,
  HABITACION     VARCHAR2(15 BYTE),
  TIPOOBS        VARCHAR2(3 BYTE),
  CLASEPAX       VARCHAR2(3 BYTE),
  TRANSGUIA      VARCHAR2(10 BYTE)
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

ALTER TABLE VENDETRESERVA
 ADD CONSTRAINT VENDETRESERVA_ESTADO_CK
 CHECK (estado in ('A','P','N'));

ALTER TABLE VENDETRESERVA
 ADD CONSTRAINT VENDETRESERVA_PK
 PRIMARY KEY
 (CIA, SUCURSAL, DOCUMENTO, SECUENCIA);

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

ALTER TABLE INV_ENCABMOVIMIENTO
MODIFY(NUM_DOCTO VARCHAR2(10 BYTE));

-- Difference : Column Order (No action taken) 

ALTER TABLE INV_ENCABTRASLADO
MODIFY(NUM_DOCTO VARCHAR2(10 BYTE));

ALTER TABLE INV_ENCABTRASLADO
MODIFY(NUM_DOCTOENT VARCHAR2(10 BYTE));

ALTER TABLE INV_HIST_ENC_MOVTO
MODIFY(NUM_DOCTO VARCHAR2(10 BYTE));

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

--
-- PLADEVIMPNOMINA  (Table) 
--
CREATE TABLE PLADEVIMPNOMINA
(
  CIA      CHAR(3 BYTE)                         NOT NULL,
  TIPOMOV  CHAR(3 BYTE)                         NOT NULL
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

ALTER TABLE PLADEVIMPNOMINA
 ADD CONSTRAINT PLADEVIMPNOMINA_PK
 PRIMARY KEY
 (CIA, TIPOMOV);

--
-- PLADEVIMPSAL  (Table) 
--
CREATE TABLE PLADEVIMPSAL
(
  CIA      CHAR(3 BYTE)                         NOT NULL,
  TIPOMOV  CHAR(3 BYTE)                         NOT NULL,
  FORMULA  VARCHAR2(80 BYTE)                    NOT NULL
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

ALTER TABLE PLADEVIMPSAL
 ADD CONSTRAINT PLADEVIMPSAL_PK
 PRIMARY KEY
 (CIA, TIPOMOV);

--
-- PLADEVPTU  (Table) 
--
CREATE TABLE PLADEVPTU
(
  CIA      CHAR(3 BYTE)                         NOT NULL,
  TIPOMOV  CHAR(3 BYTE)                         NOT NULL
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

ALTER TABLE PLADEVPTU
 ADD CONSTRAINT PLADEVPTU_PK
 PRIMARY KEY
 (CIA, TIPOMOV);

-- Difference : Column Order (No action taken) 

ALTER TABLE INV_DETMOVIMIENTO
MODIFY(NUM_DOCTO VARCHAR2(10 BYTE));

ALTER TABLE INV_HIST_DET_MOVTO
MODIFY(NUM_DOCTO VARCHAR2(10 BYTE));

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

-- Difference : Column Order (No action taken) 

ALTER TABLE INV_DETMOVDESP
MODIFY(NUM_DOCTO VARCHAR2(10 BYTE));

ALTER TABLE INV_DETMOVDESP
MODIFY(NUM_DESPACHO VARCHAR2(10 BYTE));

ALTER TABLE PLAABOPRE
 DROP CONSTRAINT PLAABOPRE_INDPLANILL_CK;
ALTER TABLE PLAABOPRE
 ADD CONSTRAINT PLAABOPRE_INDPLANILL_CK
 CHECK (indplanilla in ('A','C','L','E','O','M'));

ALTER TABLE VENPARAMETROS
 ADD CONSTRAINT VENPARAMETROS_TIPOEST_CK
 CHECK (TIPOEST IN ('F','N','D'));

ALTER TABLE PLACCOSTOEMP
 DROP CONSTRAINT PLACCOSTOEMP_PORCENTAJE_CK;
ALTER TABLE PLACCOSTOEMP
 ADD CONSTRAINT PLACCOSTOEMP_PORCENTAJE_CK
 CHECK (PORCENTAJE > 0);

ALTER TABLE PLAIMPSAL
 ADD CONSTRAINT PLAPLANILLA_IMPSAL_FK 
 FOREIGN KEY (CIA, PLANILLA) 
 REFERENCES PLAPLANILLA (CIA,PLANILLA);

ALTER TABLE PLAIMPSALCREDITO
 ADD CONSTRAINT PLAPLANILLA_IMPSALCREDITO_FK 
 FOREIGN KEY (CIA, PLANILLA) 
 REFERENCES PLAPLANILLA (CIA,PLANILLA);

ALTER TABLE PLAIMPSALSUBSIDIO
 ADD CONSTRAINT PLAPLANILLA_IMPSALSUBSIDIO_FK 
 FOREIGN KEY (CIA, PLANILLA) 
 REFERENCES PLAPLANILLA (CIA,PLANILLA);

ALTER TABLE VENDETRESERVA
 ADD CONSTRAINT VENDETPEDIDO_RESERVA_FK 
 FOREIGN KEY (CIA, SUCURSAL, DOCUMENTO, SECUENCIA) 
 REFERENCES VENDETPEDIDO (CIA,SUCURSAL,DOCUMENTO,SECUENCIA);

ALTER TABLE PLADEVIMPNOMINA
 ADD CONSTRAINT PLAMOVDEV_DEVIMPNOMINA_FK 
 FOREIGN KEY (CIA, TIPOMOV) 
 REFERENCES PLAMOVDEV (CIA,TIPOMOV);

ALTER TABLE PLADEVIMPSAL
 ADD CONSTRAINT PLAMOVDEV_DEVIMPSAL_FK 
 FOREIGN KEY (CIA, TIPOMOV) 
 REFERENCES PLAMOVDEV (CIA,TIPOMOV);

ALTER TABLE PLADEVPTU
 ADD CONSTRAINT PLAMOVDEV_DEVPTU_FK 
 FOREIGN KEY (CIA, TIPOMOV) 
 REFERENCES PLAMOVDEV (CIA,TIPOMOV);

_