On Fri, Jun 06, 2003 at 08:29:12AM +0200, Kristian Nielsen wrote: > Hi, > > We could use proper execute_array() support in DBD::Oracle, and having > already fiddled a bit with the code I am considering having a go at > implementing it (no promises though). > > Not being sure where to start, I was hoping to get a hint or two? Just > something simple like "You need to implement such-and-such function in > foo.xs" and "look at functions so-and-so in DBD::XXX for an example" > would be perfect to get me going. > > Any pointers?
Seeing your message has prompted me to add something I'd been meaning to do for a while that will simplify this somewhat: =item C<execute_for_fetch> $rv = $sth->execute_for_fetch($fetch_tuple_sub); $rv = $sth->execute_for_fetch($fetch_tuple_sub, [EMAIL PROTECTED]); The execute_for_fetch() method is used to perform bulk operations and is most often used via the execute_array() method, not directly. The fetch subroutine, referenced by $fetch_tuple_sub, is expected to return a reference to an array (known as a 'tuple') or undef. The execute_for_fetch() method calls $fetch_tuple_sub, without any parameters, until it returns a false value. Each tuple returned is used to provide bind values for an $sth->execute(@$tuple) call. Returns the number of tuples fetched and executed. If [EMAIL PROTECTED] is passed then the execute_for_fetch method uses it to return status information. The tuple_status array holds one element per tuple. If the corresponding execute() did not fail then the element holds the return value from execute(), which is typically a row count. If the execute() did fail then the element holds a reference to an array containing ($sth->err, $sth->errstr, $sth->state). Although each tuple returned by $fetch_tuple_sub is effectively used to call $sth->execute(@$tuple_array_ref) the exact timing may vary. Drivers are free to accumulate sets of tuples to pass to the database server in groups for more efficient execution. =cut So now drivers wanting to support bulk operations do not need to implement the full execute_array API, they just need to implement execute_for_fetch(). For DBD::Oracle you need to setup a callback so *Oracle* will call the $fetch_tuple_sub code ref (via a C wrapper) to get the next row :) I don't have time to help much but if you ask me clue-full questions as you go along then I'll help where I can. And, thanks! Tim.
