[firebase-br] RES: RES: ERROR:violation of FOREIGN KEY constraint
Paulo Geloramo
paulogeloramo em terra.com.br
Seg Out 10 19:26:03 -03 2011
Firebird 2.5.1
Este SQL retorna os 15 registros orfãos que quero deletar da tabela filha.
SELECT DISTINCT I.ID_NOTA_PONTO
FROM NOTA_PONTO_ITEM I
LEFT JOIN NOTA_PONTO N ON N.ID_NOTA_PONTO = I.ID_NOTA_PONTO
WHERE N.ID_NOTA_PONTO IS NULL
Tentei deletar os registros orfãos com este SQL abaixo, mas retorna erro:
multiple rows in singleton select.
DELETE
FROM NOTA_PONTO_ITEM X
WHERE X.ID_NOTA_PONTO =
(SELECT DISTINCT I.ID_NOTA_PONTO
FROM NOTA_PONTO_ITEM I
LEFT JOIN NOTA_PONTO N ON N.ID_NOTA_PONTO = I.ID_NOTA_PONTO
WHERE N.ID_NOTA_PONTO IS NULL)
Tentei deletar os registros orfãos com este SQL abaixo:
Não retornou erro, mas ficou processando por horas e
travou o IBExpert:
DELETE
FROM NOTA_PONTO_ITEM X
WHERE X.ID_NOTA_PONTO =
(SELECT DISTINCT I.ID_NOTA_PONTO
FROM NOTA_PONTO_ITEM I
LEFT JOIN NOTA_PONTO N ON N.ID_NOTA_PONTO = I.ID_NOTA_PONTO
WHERE I.ID_NOTA_PONTO = X.ID_NOTA_PONTO AND N.ID_NOTA_PONTO IS NULL)
Alguma sugestão?
Mais detalhes sobre a lista de discussão lista