/******************************************************************************/
/***               Generated by IBExpert 23/03/2021 15:36:48                ***/
/******************************************************************************/

/******************************************************************************/
/***      Following SET SQL DIALECT is just for the Database Comparer       ***/
/******************************************************************************/
SET SQL DIALECT 3;



/******************************************************************************/
/***                                 Tables                                 ***/
/******************************************************************************/

CREATE GENERATOR PQ_SAIDASM;

CREATE TABLE SAIDASM (
  SDM_ID INTEGER NOT NULL,
  SDM_TIPOMOV INTEGER DEFAULT 0,
  SDM_SITUACAO VARCHAR(1) DEFAULT 'P',
  SDM_NRDOC varchar(12),
  SDM_DTEMISSAO date,
  SDM_HREMISSAO time,
  SDM_USUEMISSAO INTEGER,
  SDM_DTPREVISAO date,
  SDM_DTCONCLUSAO date,
  SDM_IDEMPRESA INTEGER,
  SDM_NRTERMINAL INTEGER,
  SDM_IDCLIENTE INTEGER,
  SDM_CONTATO varchar(20),
  SDM_IDTECNICO INTEGER DEFAULT 0,
  SDM_IDCAIXAEMISSAO INTEGER,
  SDM_SUBTOTAL decimal(14,2) DEFAULT 0.00,
  SDM_DESCONTO decimal(14,2) DEFAULT 0.00,
  SDM_ACRESCIMO decimal(14,2) DEFAULT 0.00,
  SDM_TOTPROD decimal(14,2) DEFAULT 0.00,
  SDM_TOTSERV decimal(14,2) DEFAULT 0.00,
  SDM_TOTAL decimal(14,2) DEFAULT 0.00,
  SDM_IDNF INTEGER DEFAULT 0,
  SDM_MOVESTFIN VARCHAR(1) DEFAULT 'S',
  SDM_SOLICITACAO BLOB SUB_TYPE 0 SEGMENT SIZE 80,
  SDM_IDENDERECO INTEGER,
  SDM_DTLIBERACAO date ,
  SDM_LOCAL varchar(50) ,
  SDM_BACKUP varchar(15) ,
  SDM_NRSAT varchar(15)

);




/******************************************************************************/
/***                              Primary Keys                              ***/
/******************************************************************************/

ALTER TABLE SAIDASM ADD PRIMARY KEY (SDM_ID);


/******************************************************************************/
/***                                Triggers                                ***/
/******************************************************************************/


SET TERM ^ ;



/******************************************************************************/
/***                          Triggers for tables                           ***/
/******************************************************************************/



/* Trigger: INSSAIDASM */
CREATE OR ALTER TRIGGER INSSAIDASM FOR SAIDASM
ACTIVE BEFORE INSERT POSITION 0
AS
begin
NEW.SDM_ID=GEN_ID(PQ_SAIDASM,1);
end
^


SET TERM ; ^



/******************************************************************************/
/***                               Privileges                               ***/
/******************************************************************************/


