I know the generalized function relation $\frac 1{x-\omega+i\epsilon}=\frac 1{x-\omega}-\pi i \delta(x-\omega)$, where the first term on the right hand side is understood as principle value. However there is an integration which could give different answer when using this relation differently. The problem is as follows, in one way \begin{eqnarray} &&\int d\omega \frac {f(\omega)}{(x-\omega+i\epsilon)(y-\omega-i\epsilon)} \\&=&\int d\omega\, f(\omega)\left( \frac 1 {(x-\omega)}-\pi i \delta(x-\omega)\right)\left( \frac 1 {(y-\omega)}+\pi i \delta(y-\omega)\right) \\&=&\int d\omega \frac{f(\omega)}{(x-\omega)(y-\omega)}-\pi i \frac {f(x)}{y-x}+\pi i \frac {f(y)}{x-y}+\pi^2\delta(x-y) f(x) \end{eqnarray} and in another way, \begin{eqnarray} &&\int d\omega \frac {f(\omega)}{(x-\omega+i\epsilon)(y-\omega-i\epsilon)} \\ &=&\frac 1 {y-x-i\epsilon}\int d\omega\,f(\omega)\left( \frac 1 {x-\omega+i\epsilon}-\frac 1 {y-\omega-i\epsilon}\right) \\&=& \left(\frac 1 {y-x}+\pi i\delta(y-x)\right)\int d\omega\,f(\omega)\left( \frac 1 {(x-\omega)}-\pi i \delta(x-\omega)- \frac 1 {(y-\omega)}-\pi i \delta(y-\omega)\right) \\&=&\frac 1{y-x}\int d\omega f(\omega)\left(\frac1{x-\omega}-\frac 1{y-\omega}\right)-\pi i \frac {f(x)}{y-x}+\pi i \frac {f(y)}{x-y}+2\pi^2\delta(x-y) \\&=&\int d\omega \frac{f(\omega)}{(x-\omega)(y-\omega)}-\pi i \frac {f(x)}{y-x}+\pi i \frac {f(y)}{x-y}+2\pi^2\delta(x-y)f(x)\,. \end{eqnarray} These two ways give different answers. Why and which is correct? In fact, I really want the second one to be correct.
And another question, how to do the other integration if both sign of the $i \epsilon$ are the same in the original integral? That is, \begin{eqnarray} \int d\omega \frac {f(\omega)}{(x-\omega+i\epsilon)(y-\omega+i\epsilon)} \end{eqnarray}
Thanks.