CREATE INDEX ITBREQUISICAO_OC_ITEM_02
ON TBREQUISICAO_OC_ITEM (REQUISICAO_ID);

ALTER TABLE TBREQUISICAO_OC
    ADD VINCULO_ID INTEGER;

ALTER TABLE TBORCAMENTO
    ADD FLAG_EMAIL INTEGER,
    ADD FLAG_RESPOSTA INTEGER,
    ADD DATAENVIO INTEGER,
    ADD DATARESPOSTA INTEGER;
	
ALTER TABLE TBORCAMENTO ALTER COLUMN FLAG_EMAIL
SET DEFAULT 0;

ALTER TABLE TBORCAMENTO ALTER COLUMN FLAG_RESPOSTA
SET DEFAULT 0;

CREATE OR ALTER trigger ttbemail_id for tbemail
active before insert position 0
As
Begin
  If (New.ID Is Null) Then
    New.ID = Gen_ID(gtbemail,1);
End;

CREATE TABLE TBTEMPLATE_EMAIL (
    ID INTEGER NOT NULL,
    DESCRICAO INTEGER,
    CORPO BLOB SUB_TYPE 0 SEGMENT SIZE 80);

ALTER TABLE TBTEMPLATE_EMAIL
ADD CONSTRAINT PK_TBTEMPLATE_EMAIL
PRIMARY KEY (ID);

ALTER TABLE TBTEMPLATE_EMAIL
ADD CONSTRAINT PK_TBTEMPLATE_EMAIL
PRIMARY KEY (ID);

ALTER TABLE TBTEMPLATE_EMAIL
    ALTER DESCRICAO TYPE VARCHAR(100);

