[firebase-br] Criando Trigger

Mario Rodrigues marioirodrigues em gmail.com
Qui Jun 26 16:23:50 -03 2008


Salve a todos,

To iniciando no mundo da programacao...dai o seguinte...to tentando criar
uma trigger q faça o seguinte...tenho um sistema de emprestimo de
cd...tbl_cd com id_cd, descricao e status(bem resumido)..tenho a
tbl_emprestimo onde é relacionada com o cd...blz...a trigger tem q fazer o
seguinte quando eu gravar o emprestimo a trigger muda o status do cd para
'Emprestado'...dai fiz a seguinte trigger:
CREATE TRIGGER ATUALIZA_status FOR tbl_emprestimo
ACTIVE AFTER INSERT OR UPDATE OR DELETE POSITION 0
AS
begin
  IF (INSERTING) THEN
     UPDATE tbl_cd
     SET tbl_cd.status = 'Emprestado'
     WHERE tbl_cd.id_cd = 'Disponivel';
  ELSE
  IF (DELETING) THEN
     UPDATE tbl_cd
     SET tbl_cd.status = 'Disponivel'
     WHERE tbl_cd.status = 'Emprestado';
  ELSE
IF (UPDATING) THEN BEGIN
     UPDATE tbl_cd
     SET tbl_cd.status = 'Disponivel'
     WHERE
      tbl_cd.status = 'Emprestado';
   END
end

Porem esta dando erro no momento da criação da trigger...esse erro:(uso o FB
2.0  e o IBExpert)

This operation is not defined for system tables.
unsuccessful metadata update.
DEFINE TRIGGER failed.
lock conflict on no wait transaction.
attempt to store duplicate value (visible to active transactions) in unique
index "RDB$INDEX_8".

Alguem poderia me ajudar?



Mais detalhes sobre a lista de discussão lista