Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create table garagem(
- id_carro varchar primary key,
- tipo int
- );
- create table quantidadeTotal(
- moto int,
- carro int,
- outros int
- );
- create function quantidade_trigger() returns trigger as $quantidade_trigger$
- begin
- declare qntCarro int ;
- declare qntMoto int ;
- declare qntOutros int;
- qntCarro = select count(tipo) from garagem where garagem is 1;
- qntMoto = select count(tipo) from garagem where garagem is 2;
- qntOutros = select count(tipo) from garagem where garagem is 3;
- insert into quantidadeTotal(moto, carro, outros) values (quntCarro, qntMoto, qntOutros
- end;
- $quantidade_trigger$ LANGUAGE plpgsql;
- CREATE TRIGGER quantidade_trigger BEFORE INSERT OR UPDATE ON empregados
- FOR EACH ROW EXECUTE PROCEDURE quantidade_trigger();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement