Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Need help in Perl DBI (SQLite) execute behaviour

by poj (Abbot)
on Jul 12, 2013 at 15:51 UTC ( [id://1044009]=note: print w/replies, xml ) Need Help??


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

Try
$stHandle = $dbHandle->prepare( qq{ DELETE FROM TB_SESSIONS WHERE (TB_SESSIONS.creationTime + ? ) < CAST(? AS INTEGER) } );
poj

Replies are listed 'Best First'.
Re^2: Need help in Perl DBI (SQLite) execute behaviour
by sam_bakki (Pilgrim) on Jul 13, 2013 at 12:49 UTC

    Hi poj

    Great. This works as expected. From DBI doc, I understand that DBI will do the type conversion for me from scalar automatically. Looks like in this case I need to do it manually. But why only for RHS? because LHS is doing addition, so it is converted to INTEGER automatically?

    Thanks :)

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

      Is your database field creationTime type INTEGER ?.

      You might find this statement works

      DELETE FROM session WHERE creationTime < ?

      if you make the parameter

      (time() - SESSION_MAX_LIFE_TIME)

      which I think is easier to understand

      poj

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1044009]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-24 22:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found