Re: MsSQL IsNull and undef
- From: "brian.becker" <brian.becker@xxxxxxxxx>
- Date: 25 Jul 2005 07:45:33 -0700
Wow that post really got messed up, lost my additional info and used
older test script. Anyway here is correct stuff...
This is :
EasySoft
unixODBC-2.2.11
DBD-ODBC-1.13 (with test script below)
DBI-1.48
Latest test script:
#!perl -w -I./t
use Test::More;
$| = 1;
use_ok('DBI', qw(:sql_types));
use_ok('ODBCTEST');
# to help ActiveState's build process along by behaving (somewhat) if a
dsn is not provided
BEGIN {
if (!defined $ENV{DBI_DSN}) {
plan skip_all => "DBI_DSN is undefined";
} else {
plan tests =>4;
}
}
#DBI->trace(2);
my $dbh = DBI->connect();
unless($dbh) {
# BAILOUT("Unable to connect to the database ($DBI::errstr)\nTests
skipped.\n");
exit 0;
}
$dbh->{AutoCommit} = 1;
#### testing a simple select
my $rc = 0;
my $CustomerID;
my $sql="
Declare \@CustomerID varchar(20)
SET \@CustomerID=?
select * from ORders where CustomerID =
isnull(\@CustomerID,'VINET')
";
my $sth = $dbh->prepare(qq{$sql});
$sth->bind_param(1,$CustomerID);
$sth->execute();
my $RowCount=0;
while(my $row = $sth->fetchrow_hashref())
{
$RowCount++;
}
is($RowCount,5, "bind nulls");
my $sql2="
select * from ORders where CustomerID = isnull(?,'VINET')
";
my $sth2 = $dbh->prepare($sql2);
$sth2->bind_param(1,$CustomerID);
$sth2->execute();
$RowCount=0;
while(my $row = $sth2->fetchrow_hashref())
{
$RowCount++;
}
is($RowCount,5, "bind nulls");
# Test(1);
# clean up
$sth->finish;
exit(0);
__END__
.
- References:
- MsSQL IsNull and undef
- From: brian.becker
- MsSQL IsNull and undef
- Prev by Date: MsSQL IsNull and undef
- Next by Date: RE: DBD-Oracle
- Previous by thread: MsSQL IsNull and undef
- Next by thread: MsSQL DBD::ODBC IsNull and undef
- Index(es):
Relevant Pages
|