PARLEY,JON (HP-MountainView,ex1) wrote:

>I believe that you only need to prepare the statement once (do it before the
>infinite loop). My guess is that DB2 is storing identical prepared
>statements.
>

Jon,

Thanks for your response.


Further analysis...

The following code:

my $sql = 'select SECURITY_SYMBOL, TASK_STATUS_DETAIL from 
dbprc001.T4030TASK where TASK_ID = ?';
my $hSql = $Handle->prepare($sql);
while (1) {
    $hSql->execute(12);
    $hSql->finish();
    sleep(1);
}

runs without a memory leak. Yeah!


This code still leaks memory, but it takes twice as long:

my $sql = 'select SECURITY_SYMBOL, TASK_STATUS_DETAIL from 
dbprc001.T4030TASK where TASK_ID = ?';
while (1) {
    my $Handle = DBI->connect('dbi:DB2:DBPRC001', 'sdevlin', 
'gwybodaeth', \%parameterHash);
    my $hSql = $Handle->prepare($sql);
    $hSql->execute(12);
    $hSql->finish();
    $Handle->disconnect();
    sleep(1);
}


In both loops, if I print out $Handle->{Kids} and $Handle->{KidsActive} 
after the $hSql->finish() statement, I get 1 and 0 respectively.


This code was put together by pulling code from a larger program. The 
real program constructs SQL statements based on user input and returns 
the results. As such, I do not know what SQL will be executed against 
the database until run time. Does this mean that I need to cache SQL 
statements and their corresponding handles? Not my favoured approach 
since, essentially, I would be wrapping DBI and overloading the prepare 
statement.

Shawn

-- 
This communication is intended to be received by the individual or
entity to whom or to which it is addressed and it contains information
that is privileged, confidential and subject to copyright of 
Recognia Inc. Any unauthorized use, copying, review or
disclosure is prohibited. If received in error, please contact me by
phone at 613-623-6159 or by email at mailto:[EMAIL PROTECTED].



Reply via email to