Problem with Long Varchar Ingres Linux
am 28.05.2007 01:06:21 von SteveBI am having a problem with fetching rows of data contain long varchar
data types. Subsequent rows are returning data from previous rows.
I am using DBI-1.52 and DBD-Ingres-0.51 running on Red Hat Linux 4.4.
The version of Ingres is II 9.0.4 (a64.lnx/105)NPTL
The results of perl -v is: This is perl, v5.8.5 built for
x86_64-linux-thread-multi
I created a test data table with this structure
Column Name Type Length Nulls Defaults Seq
id_no integer 4 no yes
comment long varch yes null
I populated the table with test data like this:
101
102
103 This is a test comment.
104
105
The comment is empty for all id_no's except 103.
The following program demonstrates the problem.
#!/usr/bin/perl -w
use strict;
use DBI;
my $dbh;
my $sth;
my $sql;
my $id_no;
my $comment;
$dbh = DBI->connect('DBI:Ingres:hpa', 'ingadm', 'password',
{AutoCommit=>1, LongReadLen=>10000, LongTruncOk=>1} )
or die "Couldn't connect to database: " . DBI->errstr;
$sql = qq{
SELECT id_no, comment
FROM test
ORDER BY id_no
};
$sth = $dbh->prepare($sql)
or die "Couldn't prepare statement: " . $dbh->errstr;
$sth->execute()
or die "Couldn't execute statement: " . $sth->errstr;
while ( ($id_no, $comment) = $sth->fetchrow_array ) {
print "$id_no\t$comment\n";
#
# adding a line like this makes no difference
# $comment = "";
}
$sth->finish;
$dbh->disconnect;
The results of running the program are:
101
102
103 This is a test comment.
104 his is a test comment.
105 his is a test comment.
Why does the comment show up for id_no 104 and 105?
And why is the first letter chopped off? How do I fix this?
I am migrating an application running on a platform using SCO OpenServer
5.0.5 and Ingres II 2.0/9808 (sos_us5/00) to Linux and the open source
Ingres II 9.0.4 (a64.lnx/105)NPTL.
The program runs correctly on the SCO OpenServer/Ingres II platform.
Steve