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.


In reply to Need help in Perl DBI (SQLite) execute behaviour by sam_bakki

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.