Blob/Memo fields with DBI

A little background:

Developing a simple DBI script that connects to my Access 97 database using ODBC to pull some data out. The data rows consist of a couple of text fields and one large memo field.

The problem? It works on rows with small fields, but if the memo field is large, it fails. I can't seem to get it to read anything out. The code is as follows:

$sth = $dbh->prepare( "
      SELECT * FROM Main1 WHERE id = 2
      " );
                         
if ( !defined $sth ) {
      die "Cannot prepare statement: $DBI::errstr\n";
}
                                     
# Execute the statement at the database level
$sth->execute;

# Fetch the rows back from the SELECT statement
@row = $sth->fetchrow;

for $tt (@row)
{
      print $tt."\n";
}
IshaniAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

windfallCommented:
I have had the same problem... Here is how I fixed it....

#This is the Generic Link to the database
#Now connect to database
$dbhndl = (DBI->connect ('DBI:ODBC:something database',"something","something"));
#log and die if we do not connect
&log_and_die($DBI::errstr) unless $dbhndl;
#Send the SQL call and check that it is good

#Place the following to handle long variables
$dbhndl->{'LongReadLen'} = 6000 ; # to better handle long variables



#create the following sql query
$sql = "SELECT * FROM whatever  WHERE (something) ORDER BY (whatever)DESC";

$sth = $dbhndl->prepare($sql);
&log_and_die($sth->errstr) unless $sth;
#Now execute this query
$sth->execute || &log_and_die($sth->err);
#Make a while loop through all the returned rows
while (@row =$sth->fetchrow)
{
      #now format column <--> row using my
      my $columnname= $row[0];
      my $columnname= $row[1];
      my $columnname= $row[2];
      my $columnname= $row[3];
      etc
}
$sth->finish;
#We are done with this db-handle now.
$dbhndl->disconnect();
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IshaniAuthor Commented:
Top. It works. Thanks!

Btw, do you know of any performance hits that this would cause?
0
windfallCommented:
No, I really don't have a clue....
I use this Perl DBI with WIN NT =>ODBC=>MS SQL7 on an Emergency Room Patient/Staffing  Intranet....so my user base is relatively low and, my database would be small and my server and bandwidth resource is high compared to some WWW database applications....Maybe one of the REAL gurus (OZO? or PRAKASHK?) would know or you could check out the mailing list for the DBI at:
http://www.bitmechanic.com/mail-archives/dbi-users/
Have a good one!


0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.