<DIV>
<DIV>Hello List,</DIV>
<DIV> </DIV>
<DIV>I would like to handle two ogrlayers from a postgres database. When using getnextfeature or executesql in nested loops it fails. I am not sure if it is that either ogr is supposed to work this way or if it's just me ...</DIV>
<DIV> </DIV>
<DIV>any help is appreciated!</DIV>
<DIV> </DIV>
<DIV>Thanks,</DIV>
<DIV>Thomas</DIV>
<DIV> </DIV>
<DIV>the counter returns the correct record number of 242 if I exclude the nested while loop (getnext on layer2), but it returns 1 as it is ...</DIV>
<DIV> </DIV>
<DIV>here is a basic version of the code:</DIV>
<DIV> </DIV>
<DIV><FONT size=2>
<P>OGRLayer *poLayer1;</P>
<P>OGRLayer *poLayer2;</P>
<P></FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> counter=0;</P>
<P>OGRRegisterAll(); </P>
<P>poDS = OGRSFDriverRegistrar::Open( "PG:user=postgres password=*** dbname=*** host=localhost port=5432", TRUE );</P>
<P>poLayer1 = poDS->GetLayerByName("test242");</P>
<P>poLayer2 = poDS->GetLayerByName("test3");</P>
<P>OGRFeature *poFeatureL1;</P>
<P>poLayer1->ResetReading();</P>
<P></FONT><FONT color=#0000ff size=2>while</FONT><FONT size=2>( (poFeatureL1 = poLayer1->GetNextFeature()) != NULL )</P>
<P>{</P>
<P>OGRFeature *poFeatureL2; </P>
<P>poLayer2->ResetReading();</P>
<P></FONT><FONT color=#0000ff size=2>while</FONT><FONT size=2>( (poFeatureL2 = poLayer2->GetNextFeature()) != NULL )</P>
<P>{</P>
<P></P>
<P>}</P>
<P>counter++; </P>
<P>}</P>
<P>cout << counter;</P>
<P> </P>
<P>same thing happens if I use executesql instead of the second while loop :<FONT size=2></P>
<P>poLayer2 = poDS->ExecuteSQL("SELECT * FROM temp2",NULL,NULL);)</P></FONT></FONT></DIV></DIV><p>
                <hr size=1> <a href="http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=36035/*http://music.yahoo.com/unlimited/">Yahoo! Music Unlimited - Access over 1 million songs. Try it free.</a>