Это старая версия документа.
BEGIN devidx=0; for select distinct ci.devidx from cardidx ci where (ci.id_db=:iddb) and (ci.id_dev=:iddev) order by ci.devidx into :curdevidx do begin if (devidx<>curdevidx) then break; else devidx=devidx+1; end if (devidx=curdevidx) then devidx=devidx+1; suspend; END