CREATE TABLE V_DESPESA_AVULSA (
ID_V_DESPESA_AVULSA INTEGER NOT NULL PRIMARY KEY,
FORMA_PAG VARCHAR(30),
DINHEIRO DECIMAL(15,2),
VISA DECIMAL(15,2),
MASTER DECIMAL(15,2),
HIPER DECIMAL(15,2),
CHEQUE DECIMAL(15,2),
DEBVISA DECIMAL(15,2),
DEBMASTER DECIMAL(15,2),
USUARIO VARCHAR(10),
DATA DATE,
HORA TIME
);

CREATE TABLE V_I_DESPESA_AVULSA (
ID_V_I_DESPESA_AVULSA INTEGER NOT NULL PRIMARY KEY,
ID_V_DESPESA_AVULSA INTEGER,
ID_P_S INTEGER,
QTD INTEGER,
VALOR_UNIT DECIMAL(15,2),
COMANDA INTEGER,
TAXA DECIMAL(3,2)
);


CREATE GENERATOR GEN_ID_V_I_DESPESA_AVULSA;

SET TERM ^;

CREATE TRIGGER TRIG_GEN_ID_V_I_DESPESA_AVULSA FOR V_I_DESPESA_AVULSA
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
   NEW.ID_V_I_DESPESA_AVULSA  = gen_id(GEN_ID_V_I_DESPESA_AVULSA ,1);
END
^

COMMIT WORK^
SET TERM;^


UPDATE PARAMETROS SET SCRIPT = 133;
