File: testclob.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 (40 lines) | stat: -rw-r--r-- 934 bytes parent folder | download | duplicates (2)
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
#!perl -w
# $Id: testclob.pl 11680 2008-08-28 08:23:27Z mjevans $

use DBI;

my $dbh = DBI->connect()
	or die "$DBI::errstr\n";

$dbh->{PrintError} = 0;
eval {
   # if it's not already created, the eval will silently ignore this
   $dbh->do("drop table longtest;");
};

$dbh->{RaiseError} = 1;
$dbh->do("create table longtest (id integer primary key, value CLOB)");

my %foo;

$foo{2} = "Hello there.";
$foo{1} = "This is a test of CLOB.  "x200;
my $tracefile = "dbitrace.log";
if (-e $tracefile) {
   unlink($tracefile);
}
DBI->trace(9,$tracefile);
my $sth = $dbh->prepare("insert into longtest values (?, ?)");
$sth->execute((2, $foo{2}));
$sth->execute((1, $foo{1}));

$dbh->{LongReadLen} = 2000000;
my $sth2 = $dbh->prepare("select id, value from longtest order by id");
$sth2->execute;
my @row;
while (@row = $sth2->fetchrow_array) {
   print join(', ', @row), "\n";
}

$dbh->disconnect;