perl - prepare_cached dbi inside a recursion -


ii using dbi call table on db recurisvly when use prepare function every thing works fine when use prepare_cached instead error message prepare_cached failed

below snippet of code

sub rec {  $data = shift; $dbh = shift;  if($x eq 'foo') {   return 1;  }  $query="select x table z =?";  $sth=$dbh->prepare_cached($query); $sth= $dbh->execute($data);   while(my ($x)=$sth->fetchrow_array) {    $rec($x,$dbh);  }  } 

could problem ?

the problem iterating on $sth , while doing this, recursing , executing again. since acts on same $sth can't work (prepare_cached call $sth->finish, see dbi docs).

so if possible, fetch rows array, $sth->finish , recurse on array. or use normal prepare(). depending on dbs might performant enough.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -