<div>Thanks Ralf for your suggestion.</div>
<div> </div>
<div>I solved it by doing it in two steps.</div>
<div>First, I created a temporary table with the donut geometry:</div>
<div> </div>
<div>EXECUTE 'create table tempdonut as SELECT ST_Difference(st_buffer(the_geom,buffer_radius), the_geom) as the_geom<br> from designprocess.dp_zn_boundaries<br> where type = site_name);</div>
<div> </div>
<div>Second, I did de Intersects query:</div>
<div> </div>
<div>EXECUTE 'INSERT INTO tempdonut SELECT<br> r.the_geom, r.gid FROM urbanenvironment.ue_ms_crossings_wegdeel_punt AS r, tempdonut as m<br> WHERE ST_Intersects(r.the_geom, m.the_geom)';</div>
<div> </div>
<div>Thanks again,</div>
<div> </div>
<div>júlio almeida</div>