You are on page 1of 1

DELIMITER $$ CREATE Procedure INSERTAR (in idp int,in idtic int) BEGIN Declare @mensaje varchar(100); @si int;

@noo int; @VAux int; @iva int; if (select count(*) from producto where idproducto=idp) > 0 then select costo into @VAux, gravado into @iva from producto where idproduc to = idp; if(@iva = 1)then set @si = (@VAux * .15); set @noo = (@VAux * 1.15); insert into asigancion values (idtic,idp,@noo,@si); else insert into asigancion values (idtic,idp,@VAux,0); end if else set @mensaje= 'El producto no existe'; select @mensaje; end if END $$ DELIMITER ;

DROP TABLE IF EXISTS `ticket`.`asignacion`; CREATE TABLE `ticket`.`asignacion` ( `idticket` int(11) default NULL, `idproducto` int(11) default NULL, `total` int(10) unsigned NOT NULL default '0', `subtotal` int(10) unsigned NOT NULL default '0' ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

DROP TABLE IF EXISTS `ticket`.`producto`; CREATE TABLE `ticket`.`producto` ( `idproducto` int(10) unsigned NOT NULL auto_increment, `costo` int(11) NOT NULL, `gravado` varchar(2) NOT NULL, PRIMARY KEY (`idproducto`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; DROP TABLE IF EXISTS `ticket`.`ticket`; CREATE TABLE `ticket`.`ticket` ( `idticket` int(11) NOT NULL, `clave_producto` int(11) NOT NULL, `Total` int(11) default NULL, `subtotal` int(10) unsigned NOT NULL default '0' ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

You might also like