1
I’m having trouble with Trigger where:
- The table
itens_compra_fornecedor
through the columnvalor_compra
calculates the resale price of the columnvalor_revenda
on the tableproduto
that has no effect. - And also Trigger’s other action is to update the field
data_relatorio_compra
tablerelatorio_compra_fornecedor
that does not return the date.
Diagram
Trigger to calculate the resale value is that
create or replace function preco_revenda()
returns trigger as $$
begin
new.valor_revenda := (select sum (itens_compra_fornecedor.valor_compra + (itens_compra_fornecedor.valor_compra * 0.5))
from produto where produto.cd_itens_compra_fornecedor = new.cd_itens_compra_fornecedor);
update relatorio_compra_fornecedor set data_compra_fornecedor = now()
from relatorio_compra_fornecedor where relatorio_compra_fornecedor.cd_relatorio_compra_fornecedor = new.cd_relatorio_compra_fornecedor;
return new;
end
$$ language plpgsql;
create trigger preco_revenda
before insert or update on produto
for each row
execute procedure preco_revenda();
If you want me to update the picture to show the whole bank let me know, only I can ask for help to other Rigger if you need, helping me to fire this report I can use the code to also fire other triggers of product sales report and return report.
– user185354
Please just don’t close my question, because I really need help in making my web system for college stuff.
– user185354
Can’t you do both actions on the same trigger? Is there another reason why it’s two triggers?
– anonimo
@anonimo I thought I could perform two actions on the same trigger.
– user185354
Then put on your trigger an update of the supplier.
– anonimo
@anonymity
update relatorio_compra_fornecedor set data_compra_fornecedor = now() from relatorio_compra_fornecedor where relatorio_compra_fornecedor.cd_relatorio_compra_fornecedor = new.cd_relatorio_compra_fornecedor;
?– user185354