DBD-ODBC
view release on metacpan or search on metacpan
Removed some dead HTTP links in the pod I could not find equivalents for
- let me know if you have working replacements for ones removed
Add some HTTP links to useful tutorials on DBD::ODBC
1.13 2004-11-08
Fix inconsistency/bug with odbc_exec_direct vs. odbc_execdirect
settings. Now made consistent with odbc_exec_direct. For now, will
still look for odbc_execdirect in prepare, but not as DBH attribute as a
backup (which is what it was doing), but that support will be dropped at
some time in the future. Please use odbc_exec_direct from now on...
Fix handling of print statements for SQL Server thanks to Martin Evans!
Thanks for all your work on this!
Due to bug in SQL Server, you must use odbc_exec_direct. See
t/20SqlServer.t for example. You will need to call
$sth->{odbc_more_results} to clear out any trailing messages.
Change tests to use Test::More. Whew, that's much nicer!
Added tracing into SQLBindParameter (help diagnose oracle odbc bug)
Fixed/worked around bug/result from Latest Oracle ODBC driver where in
SQLColAttribute cbInfoValue was changed to 0 to indicate fDesc had a value
Added work around for compiling w/ActiveState PRK (PERL_OBJECT)
Updated tests to include date insert and type
Added more "backup" SQL_xxx types for tests
Updated bind test to test binding select
NOTE: bind insert fails on Paradox driver (don't know why)
Added support for: (see notes below)
SQLGetInfo via $dbh->func(xxx, GetInfo)
SQLGetTypeInfo via $dbh->func(xxx, GetTypeInfo)
SQLDescribeCol via $sth->func(colno, DescribeCol)
are sent. See DBI's cancel method and if you destroy a statement
handle with pending results, call cancel before destruction.
However, you are best not selecting rows you have no intention of
retrieving.
See cancel_big_fetch.pl in the DBD::ODBC examples dir. NOTE: more recent
MS SQL Server drivers are better in this respect and sometimes the test
script cancel_big_fetch.pl shows no difference.
=head2 Why does my backup/restore/some_other_procedure in MS SQL Server not complete?
MS SQL Server batches up results in a procedure. A result may be the
output of a print or a select or in some cases even an insert/update
(see SET NOCOUNT ON|OFF). If you attempt to call a procedure using the
C<do> method and it outputs results (e.g., a print statement saying
the % completed) the procedure probably will not fully
complete. Instead you should do the following:
$sth-prepare(call to my procedure);
$sth->execute;
dbdimp.c
dbdimp.h
dbivport.h
fixup_c.h
fixup_t.h
FAQ
Makefile.PL
MANIFEST This list of files
META.yml
test_results.txt
examples/backup_restore.pl
examples/big_result.pl
examples/cancel_big_fetch.pl
examples/column_info.pl
examples/DbiTest.pl
examples/DbiTest2.pl
examples/dml_counts.pl
examples/enable_odbc_tracing.pl
examples/execute_for_fetch.pl
examples/getinfo.pl
examples/identity.pl
handle for do().
DBD::ODBC implements C<do> by calling SQLExecDirect in ODBC and not
SQLPrepare followed by SQLExecute so C<do> is not the same as:
$dbh->prepare($sql)->execute()
It does this to avoid a round-trip to the server so it is faster.
Normally this is good but some people fall foul of this with MS SQL
Server if they call a procedure which outputs print statements (e.g.,
backup) as the procedure may not complete. See the DBD::ODBC FAQ and
in general you are better to use prepare/execute when calling
procedures.
In addition, you should realise that since DBD::ODBC does not create a
DBI statement for do calls, if you set up an error handler the handle
passed in when a do fails will be the database handle and not
a statement handle.
=head3 Mixed placeholder types
examples/backup_restore.pl view on Meta::CPAN
# $Id$
# backup and restore a MS SQL Server database
# needs to loop over odbc_more_results or the procedure does not finish
use DBI;
use strict;
use warnings;
use Data::Dumper;
sub _error_handler {
print Dumper(\@_);
0;
}
my $h = DBI->connect;
$h->{RaiseError} = 1;
$h->{HandleError} = \&_error_handler;
eval {$h->do('create database foo');};
$h->do(q{backup database foo to disk='c:\foo.bak'});
my $s = $h->prepare(q{restore database foo from disk='c:\foo.bak'});
$s->execute;
while ($s->{odbc_more_results}) {
print "More\n";
}
( run in 1.540 second using v1.01-cache-2.11-cpan-49f99fa48dc )