From: Brian C. <B.C...@po...> - 2003-03-31 18:00:35
|
On Mon, Mar 31, 2003 at 10:39:00AM -0600, Paul DuBois wrote: > At 15:07 +0100 3/31/03, Brian Candler wrote: > >I was writing some code like this: > > > > s = db.prepare("select bar from foo where baz=?") > > ... > >(1) > > s.execute(key) do |sth| > > result = sth.fetch > > end > > > >Unfortunately, I discovered that it doesn't work like that - the block is > >simply ignored. > > Right. execute takes a block for a database handle, not a statement > handle. Sure. But do you have any objections to StatementHandle#execute being able to take a block? The current behaviour went against POLS for me. I was optimising existing code which looked like this: dbh.execute(stmt,args) do |sth| ... end and I was expecting to be able to replace it with p = dbh.prepare(stmt) ... p.execute(args) do |sth| ... end However the current behaviour doesn't let you do this, which means you have to rewrite your code more than I expected :-( Regards, Brian. |