Título: Hacer Triggers en un Procedimie Publicado por: HenBAl en 17 Mayo 2015, 07:58 am Como puedo hallar el subtotal automaticamente y el total (trigger), sabiendo que tengo que hacer procedimientos para cada una de las tablas y al momento de ejecutarlo se hallen automaticamente el sub y total. Tengo:
CREATE TABLE FACTURA( NUMEROFACTURA INT PRIMARY KEY, FECHA DATE NOT NULL, TOTAL MONEY NULL, FKCLIENTE INT NOT NULL, FKFEMPLEADO INT NOT NULL) CREATE TABLE DETALLE ( NUMERODETALLE INT NOT NULL, FKFACTURA INT NOT NULL, CANTIDAD INT NOT NULL, SUBTOTAL MONEY NULL, FKPRODUCTO INT NOT NULL ) CREATE TABLE PRODUCTO( CODIGO INT PRIMARY KEY, NOMBRE VARCHAR(100) NOT NULL, VALORUNIT MONEY NULL, EXISTENCIA INT NOT NULL) Ingreso un producto (con P.A) y luego a hacer una factura y luego detalle y automaticamente se hallen subtotal y total. ¿me ayudan por favor?- Ignoren las claves foraneas que no tienen que ver con el problema. |