Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-19 17:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found