in reply to Recursive dbh executions

In short, not really. The way you'll have to do this is to pull everything into memory, close the $sth, and then recurse over the data in memory.

Alternately, if you're using a database that supports this (such as Oracle or Postgres), you can use a CONNECT BY clause to have the database do the parent-child relationships for you. Or, you can use other methods that simulate that type of behavior.

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
Re^2: Recursive dbh executions
by cbrandtbuffalo (Deacon) on Mar 23, 2005 at 16:50 UTC
    I agree. As has been noted, the problem is that inside that while, you are in the middle of reading the results coming back. If you think of it at the database level, if you were working in an SQL tool and typing queries to get results, you type one query, execute, and get all the rows back. There isn't a way in mid-result fetching to run another query.

    There are ways to script things with more advanced SQL, but that can get hairy. Unless you have a memory limitation on your system, it's much easier and cleaner to pull in a full data structure, then work on that.

      It's not quite that simple. Some DBD's, such as Oracle and MySQL, can have multiple statements executing at the same time. Others, such as Sybase / SQL*Server, cannot. But, most DBD's won't let you do the same statement twice at the same time. That's the issue here.

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.