File: lob_read.pl

package info (click to toggle)
libdbd-odbc-perl 1.37-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,272 kB
  • sloc: perl: 7,932; ansic: 5,991; makefile: 33; sql: 8
file content (30 lines) | stat: -rw-r--r-- 840 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
# $Id: lob_read.pl 14632 2011-01-03 16:49:11Z mjevans $
#
# Example of DBD::ODBC's lob_read
#
#use Log::Log4perl qw(:easy);
#Log::Log4perl->easy_init($DEBUG);
#use DBIx::Log4perl;
use DBI;
use strict;
use warnings;

#$h = DBIx::Log4perl->connect("dbi:ODBC:baugi","sa","easysoft". {PrintError => 1});
my $h = DBI->connect("dbi:ODBC:baugi","sa","easysoft",
                     {PrintError => 1, RaiseError => 1, PrintWarn => 1});
my $s = $h->prepare(q{select 'frederick'});
$s->execute;
$s->bind_col(1, undef, {TreatAsLOB=>1});
$s->fetch;
# SQL_SUCCESS = 0
# SQL_SUCCESS_WITH_INFO = 1
# SQL_NO_DATA = 100
my $len;
$s->{RaiseError} = 0;
while($len = $s->odbc_lob_read(1, \my $x, 8, {Type => 999})) {
    print "len=$len, x=$x\n";
}
print "len at end = $len\n";
my $x;
$len = $s->odbc_lob_read(1, \$x, 8);
$len = $s->odbc_lob_read(1, \$x, 8);