http://qs321.pair.com?node_id=1043949

sam_bakki has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks

I am doing kind of session management for my client server based application. I use Perl DBI + SQLite to store the data into DB. I have following code,

... $self->_loggerObj()->logInfo("Cleanup Corpse sessions from DB: ".$se +lf->_sessionsDBFName()); # Prepare delete query to clean up corpse try { #Delete all the sessions where Sessions original creation time + + SESSION_MAX_LIFE_TIME < NOW $stHandle = $dbHandle->prepare( qq{ DELETE FROM TB_SESSIONS WHE +RE ( TB_SESSIONS.creationTime + ? ) < ? ; } ); }catch { $self->_loggerObj()->logError("Can not PREPARE Corpse clean up + DELETE for DB: ".$self->_sessionsDBFName()." , ".$dbHandle->errstr() +.", $_ , in removeSessionDetails"); $dbHandle->disconnect(); undef $stHandle; undef $dbHandle; #Here the main operation is success , Corpse clean up is extra +, do not report error from Corpse clean up, Just return main operatio +n # i.e removeSessionDetails's result. return SESSION_ID_REMOVED; }; #Run query try { $self->_loggerObj()->logInfo("Execute :Corpse clean up DELETE +from DB [removeSessionDetails]".SESSION_MAX_LIFE_TIME." ".time()); $dbHandle->do('BEGIN EXCLUSIVE TRANSACTION'); my $now = time(); print "\n NOW: $now"; my $rv = $dbHandle->do('DELETE FROM TB_SESSIONS WHERE ( TB_SES +SIONS.creationTime + '.SESSION_MAX_LIFE_TIME.' ) < '.$now.';'); print "\n ---1.", Dumper($rv); $rv = $stHandle->execute(SESSION_MAX_LIFE_TIME,time()); print "\n ---2.", Dumper($rv); $dbHandle->do('COMMIT TRANSACTION'); }catch { $self->_loggerObj()->logError("Can not RUN Corpse clean up DEL +ETE query for DB: ".$self->_sessionsDBFName()." , ".$dbHandle->errstr +().", $_ , in removeSessionDetails"); $dbHandle->disconnect(); undef $stHandle; undef $dbHandle; #Here the main operation is success , Corpse clean up is extra +, do not report error from Corpse clean up, Just return main operatio +n # i.e removeSessionDetails's result. return SESSION_ID_REMOVED; }; ....

Essentially I am trying to remove dead sessionIDs. I expect same output for both prints but I got following output,

NOW: 1373630196 ---1.$VAR1 = '0E0'; ---2.$VAR1 = 4;

According to my logic, I expect '0E0' , first query output is correct. This is want I want but when I pass the same arguments via prepare + execute, code is not doing what i want. Am I making some stupid mistake??

Thanks & Regards,
Bakkiaraj M
My Perl Gtk2 technology demo project - http://code.google.com/p/saaral-soft-search-spider/ , contributions are welcome.