File: cancel.pl

package info (click to toggle)
libdbd-odbc-perl 1.24-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,012 kB
  • ctags: 398
  • sloc: perl: 6,314; ansic: 4,875; makefile: 29; sql: 8
file content (45 lines) | stat: -rw-r--r-- 1,300 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!perl -w
# $Id: cancel.pl 11680 2008-08-28 08:23:27Z mjevans $

use DBI qw(:sql_types);
use Data::Dumper;
use strict;

my $dbh = DBI->connect( "dbi:ODBC:Northwind", "", "",
     {RaiseError => 1, PrintError => 1, AutoCommit => 1} );

my $sth = $dbh->prepare( "select * from Customers" );
$sth->execute( );
print "Table contains: " . $sth->{NUM_OF_FIELDS} . " columns.\n";
print "Column names are:\n\t" . join( "\n\t", @{$sth->{NAME}}, "" );

$sth->cancel;
$sth->finish;


$sth = $dbh->prepare( "select count(*) from Customers" );
$sth->execute( );
print "\nTable contains: " . $sth->{NUM_OF_FIELDS} . " columns.\n";
print "Column names are:\n\t" . join( "\n\t", @{$sth->{NAME}});

$sth->cancel;
$sth->finish;

$sth = $dbh->prepare( "select count(*) from Customers where CompanyName='FOO'" );
$sth->execute( );
print "\nTable contains: " . $sth->{NUM_OF_FIELDS} . " columns.\n";
print "Column names are:\n\t" . join( "\n\t", @{$sth->{NAME}});

$sth->cancel;
$sth->finish;


$sth = $dbh->prepare( "select count(*) from Customers where Company1Name='FOO'" );
$sth->execute( );
print "\nTable contains: " . $sth->{NUM_OF_FIELDS} . " columns.\n";
print "Column names are:\n\t" . join( "\n\t", @{$sth->{NAME}});

$sth->cancel;
$sth->finish;

$dbh->disconnect;