Jump to content
Fórum Script Brasil
  • 0

Dúvida com Trigger


greabs
 Share

Question

Desenvolva um trigger, não instead of, para a operação INSERT da tabela veículo que grave na coluna Vl_Apolice, 10% do valor do modelos abaixo de 40000 e 12% no restante

Alguém pode resolver isso? Preciso urgentemente pra uma atividade.

Somente alterar esse um pouco para poder resolver o resto.

CREATE TRIGGER T_Apolice

ON

veiculo

FOR

INSERT

AS

DECLARE @Placa CHAR(7), @Cd_Modelo INTEGER, @Valor DECIMAL(8,2)

SET @Placa = (SELECT Placa FROM INSERTED)

SET @Cd_Modelo = (SELECT Cd_Modelo FROM INSERTED)

SET @Valor = (SELECT Valor FROM Modelo WHERE Modelo.Cd_Modelo = @Cd_Modelo) * 0.1

UPDATE Veiculo SET Vl_Apolice = @valor WHERE Placa = @Placa

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Forum Statistics

    • Total Topics
      149.8k
    • Total Posts
      646.6k
×
×
  • Create New...