Fórum restrição de quantidades de registros via sql #441192
27/04/2013
0
exemplo
a tabela funcionarios so aceita o nome joao ate 25 vezes repetidamente
Edon Ramos
Curtir tópico
+ 0Posts
28/04/2013
Edon Ramos
CREATE TRIGGER "LIM_REGISTROS" FOR "PREFEITURA"
ACTIVE BEFORE INSERT POSITION 0
AS
declare variable NTOT integer;
begin
select count(*) from prefeitura where cargoflu='Assessor Diretor Nível VII' into :ntot;
if (:ntot = 2) then
exception lim_registros;
só que quando eu estou cadastrando ele não entende que é só o cargoflu ele coloca a tabela inteira....
Gostei + 0
01/05/2013
Alvaro Vieira
Abraço.
/******************************************************************************/
/**** Following SET SQL DIALECT is just for the Database Comparer ****/
/******************************************************************************/
SET SQL DIALECT 3;
SET TERM ^ ;
CREATE OR ALTER TRIGGER PREFEITURA_BI0 FOR PREFEITURA
ACTIVE BEFORE INSERT POSITION 0
AS
declare variable ntot integer;
begin
select count(*)
from prefeitura
where cargoflu=new.cargoflu
into :ntot;
if (:ntot = 2) then
exception lim_registros;
end
^
SET TERM ; ^
Gostei + 0
01/05/2013
Edon Ramos
mas ao invés de usar o before se usa o after,pois senão a trigger não volta com o ultimo valor inserido na tabela
;)
Gostei + 0
06/05/2013
William
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)