Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Pedroalves

[Resolvido] Erro ao criar triggers

Recommended Posts

não estou a conseguir por este Trigger a funcionar alguem me ajudar

CREATE DEFINER=`root`@`localhost` TRIGGER `gil`.`requizacao` BEFORE INSERT ON gil.tabela_requizicao FOR EACH ROW

BEGIN

declare X int;

select disponivel From tabela_material,tabela_requizicao where tabela_material.codmaterial=new.codmaterial into X;

set new.disponivel=new.quantidadeexistente-X;

END;

 

TABELA REQUIZICAO

 

CREATE TABLE `tabela_requizicao` (

`codrequisicao` int(11) NOT NULL AUTO_INCREMENT,

`coduser` int(11) DEFAULT NULL,

`datarequisicao` datetime DEFAULT NULL,

`datacaeite` datetime DEFAULT NULL,

`dataentrega` datetime DEFAULT NULL,

`obs` char(255) DEFAULT NULL,

`entrega` tinyint(4) DEFAULT NULL,

`avisoadmim` text,

KEY `PrimaryKey` (`codrequisicao`),

KEY `tabela_userTabela_requiziçao` (`coduser`)

) ENGINE=InnoDB AUTO_INCREMENT=274 DEFAULT CHARSET=latin1;

 

Tabela material

 

CREATE TABLE `tabela_material` (

`codmaterial` int(11) NOT NULL AUTO_INCREMENT,

`material` char(255) DEFAULT NULL,

`sn` char(255) DEFAULT NULL,

`codlaboratorio` int(11) DEFAULT NULL,

`codcategoria` int(11) DEFAULT NULL,

`obs` char(255) DEFAULT NULL,

`avisoadmim` char(255) DEFAULT NULL,

`quantidadeexistente` int(11) DEFAULT NULL,

`quantidademinima` int(11) DEFAULT NULL,

`quantidadeestragada` int(11) DEFAULT NULL,

`refmaterial` char(255) DEFAULT NULL,

`descricao` char(255) DEFAULT NULL,

`codfornecedor` int(11) DEFAULT NULL,

`disponivel` int(11) DEFAULT NULL,

PRIMARY KEY (`codmaterial`),

KEY `PrimaryKey` (`codmaterial`),

KEY `tabela_categotriatabela_material` (`codcategoria`),

KEY `Tabela_fornecedortabela_material` (`codfornecedor`),

KEY `tabela_laboratóriotabela_material` (`codlaboratorio`)

) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.