On Fri, Dec 10, 2004 at 11:32:37AM -0000, Martin J. Evans wrote: > The DBI documentation for LongReadLen includes: > > "A value of 0 means not to automatically fetch any long data. ("fetch" should > return "undef" for long fields when "LongReadLen" is 0.)" > > What is the significance of the "automatically"?
Probably a vague nod towards the possibility that some drivers may supply extra methods for reading blobs (in chunks etc). But I doubt any drivers do exactly what's specified here. Most probably just truncate to a 0 length string rather than return undef. I may loosen the spec to say that a driver "may" return undef for LONG type fields if LongReadLen is 0. > Should the following code on a long column (MS SQL Server text column) return > undef for col2 or the error I've included? > > $sth->{LongReadLen} = 0; > print "LongTruncOk is '", $sth->{LongTruncOk}, "'\n"; > print "LongReadLen is ", $sth->{LongReadLen}, "\n"; > $sth = $dbh->prepare(q/select * from table/); > $sth->execute; > my ($col1, $col2); > $sth->bind_columns(\($col1, $col2)); > while ($sth->fetch) { > print "$col1, $col2\n"; > } > > LongTruncOk is '' > LongReadLen is 0 > DBD::ODBC::st fetch failed: [unixODBC][][Microsoft][ODBC SQL Server > Driver]String data, right truncation (SQL-01004)(DBD: st_fetch/SQLFetch (long > truncated DBI attribute LongTruncOk not set and/or LongReadLen too small) > err=-1) at ./tut2_9.pl line 24. LongTruncOk is false so therefore it's an error for a long to be truncated by LongReadLen. So the error is correct. Tim.