Vous êtes sur la page 1sur 3

cracion de tablas CREATE TABLE ESTUDIANTE ( CI_EST Varchar(30) NOT NULL, NOM_EST Varchar(30), PRIMARY KEY (CI_EST) ); *******************************

CREATE TABLE LOG ( CI_EST Varchar(30), NOM_EST Varchar(30), OP_EST Char(30), FEC_EST Timestamp, USU_EST Varchar(200) );

*************************************************************** TRIGGER PARA BORRAR ************************************************************ SET TERM ^ ; CREATE TRIGGER DL_ESTUDIANTE FOR ESTUDIANTE AFTER DELETE POSITION 1 AS --declare variable IdTranzacion integer; DECLARE VARIABLE lcNombre varchar (30); DECLARE VARIABLE lcOperac char (30); DECLARE VARIABLE lnCI_est varchar (30); DECLARE VARIABLE lcfecha timestamp; DECLARE VARIABLE lcUsuario varchar (200); DECLARE VARIABLE lcComando varchar (800); DECLARE VARIABLE CODIGO INT; BEGIN lcOperac = 'D'; select MON$USER from MON$ATTACHMENTS INTO :lcUsuario; select MON$TIMESTAMP from MON$ATTACHMENTS INTO :lcfecha; lnCI_est = OLD.CI_EST; lcNombre = OLD.NOM_EST;

lcComando = 'INSERT INTO LOG (CI_EST, NOM_EST, OP_EST, FEC_EST, USU_EST) VALUES ('||''''|| lnCI_est ||''''||','||''''|| lcNombre ||''''||','||''''|| lcO perac ||''''||','||''''||lcfecha ||''''||','||''''|| lcUsuario ||''''||')'; EXECUTE STATEMENT lcComando on external DATA SOURCE 'D:/SEGUNDO Prcial/LOG.fdb ' AS user 'sysdba' password 'masterkey';

END^ SET TERM ; ^ *************************************************************** TRIGGER PARA INSERTAR ************************************************************ SET TERM ^ ; CREATE TRIGGER IN_ESTUDIANTE FOR ESTUDIANTE FOR ESTUDIANTE AFTER INSERT POSITION 1 AS --declare variable IdTranzacion integer; DECLARE VARIABLE lcNombre varchar (30); DECLARE VARIABLE lcOperac char (30); DECLARE VARIABLE lnCI_est varchar (30); DECLARE VARIABLE lcfecha timestamp; DECLARE VARIABLE lcUsuario varchar (200); DECLARE VARIABLE lcComando varchar (800); DECLARE VARIABLE CODIGO INT; BEGIN lcOperac = 'I'; select MON$USER from MON$ATTACHMENTS INTO :lcUsuario; select MON$TIMESTAMP from MON$ATTACHMENTS INTO :lcfecha; lnCI_est = NEW.CI_EST; lcNombre = NEW.NOM_EST;

lcComando = 'INSERT INTO LOG (CI_EST, NOM_EST, OP_EST, FEC_EST, USU_EST) VALUES ('||''''|| lnCI_est ||''''||','||''''|| lcNombre ||''''||','||''''|| lcO perac ||''''||','||''''||lcfecha ||''''||','||''''|| lcUsuario ||''''||')'; EXECUTE STATEMENT lcComando on external DATA SOURCE 'D:/SEGUNDO Prcial/LOG.fdb ' AS user 'sysdba' password 'masterkey'; END^ SET TERM ; ^ *************************************************************** TRIGGER PARA ACTUALIZAR ************************************************************ SET TERM ^ ; CREATE TRIGGER UP_ESTUDIANTE FOR ESTUDIANTE FOR ESTUDIANTE AFTER DELETE POSITION 1 AS --declare variable IdTranzacion integer; DECLARE VARIABLE lcNombre varchar (30); DECLARE VARIABLE lcOperac char (30);

DECLARE DECLARE DECLARE DECLARE BEGIN

VARIABLE VARIABLE VARIABLE VARIABLE

lnCI_est varchar (30); lcfecha timestamp; lcUsuario varchar (200); lcComando varchar (800);

lcOperac = 'U'; select MON$USER from MON$ATTACHMENTS INTO :lcUsuario; select MON$TIMESTAMP from MON$ATTACHMENTS INTO :lcfecha; lnCI_est = OLD.CI_EST; lcNombre = OLD.NOM_EST;

lcComando = 'INSERT INTO LOG (CI_EST, NOM_EST, OP_EST, FEC_EST, USU_EST) VALUES ('||''''|| lnCI_est ||''''||','||''''|| lcNombre ||''''||','||''''|| lcO perac ||''''||','||''''||lcfecha ||''''||','||''''|| lcUsuario ||''''||')'; EXECUTE STATEMENT lcComando on external DATA SOURCE 'D:/SEGUNDO Prcial/LOG.fdb ' AS user 'sysdba' password 'masterkey'; END^ SET TERM ; ^