shemp has asked for the wisdom of the Perl Monks concerning the following question:
End update
I am working on a program that is querying a remote DB2 server for some data. In a test run, i am getting an error preparing a query. The query is nothing complicated, its like:
SELECT LIST_NBR, PARCEL_NBR FROM list WHERE PARCEL_NBR = '0540040'
I'm running basically the same query over and over, with a different value for PARCEL_NBR. (yes i'll add bind_params when things begin working). Anyway, regardless of where i start in my list, i get an error on the 1327th iteration. Even if i keep asking for the same values, it dies on the 1327 iteration.
Here is a VERY stripped down version of what im doing, which still gives the error:
The error I'm getting is:use strict; use warnings; use DBI; use DBD::DB2; $ENV{'DB2INSTANCE'} = [...]; { my $db_handle = DBI->connect('DBI:DB2:FLEX', [user], [pass], { 'RaiseError' => 1, 'PrintError' => 1, }, ) or die "couldnt connect to FLEX db $?\n"; my $taxkey = '0540040'; for my $i (0 .. 1400) { print "COUNT: $i\n"; find_listings_for_parcel($db_handle, $taxkey); } $db_handle->disconnect(); } sub find_listings_for_parcel { my ($db_handle, $taxkey) = @_; my $query = "SELECT LIST_NBR, PARCEL_NBR FROM list " . " WHERE PARCEL_NBR = " . $db_handle->quote($taxkey); my $query_handle; eval { $query_handle = $db_handle->prepare($query); }; if ( $@ ) { print "QUERY: $query\n"; exit; } eval { $query_handle->execute(); }; if ( $@ ) { print "QUERY: $query\n"; exit; } $query_handle->finish(); }
This must be some sort of memory leak or resource clash, because it is doing the same thing over and over, and eventually dies after many iterations. I have tried with other PARCEL_NBR values, with the same result.... COUNT: 1326 DBD::DB2::db prepare failed: [IBM][CLI Driver][DB2/SUN64] SQL0805N Pa +ckage "NULLID.SYSLH203 0X5359534C564C3031" was not found. SQLSTATE=5 +1002 QUERY: SELECT LIST_NBR, PARCEL_NBR FROM list WHERE PARCEL_NBR = '0540 +040'
Oh, LIST_NBR is 'integer not null'
and PARCEL_NBR is 'varchar(50)'
Any ideas?
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBD::DB2 prepare() error
by castaway (Parson) on Sep 27, 2004 at 20:37 UTC |