La solucián era:
Código Delphi
[-]
CREATE PROCEDURE NEW_PROCEDURE (
acometedor integer)
returns (
id integer,
acometido integer)
as
begin
FOR SELECT id,acometido
FROM MIA
WHERE id = :acometedor
INTO :id,:acometido
DO BEGIN
if (acometido is not null)
then begin
SUSPEND;
for select id, acometido
from NEW_PROCEDURE(:acometido)
into :id,:acometido
do begin
if (acometido is not null)
then SUSPEND;
end
end
END
end^
De esta forma va buscando recursivamente y busca en los dos campos el orden jerarquico.
Gracias.
Perdón, sustituir id por PRINCIPAL y acometido por SECUNDARIO.