Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Perl style/best practice question: how to [better] embed SQL in code ?

by ccn (Vicar)
on Dec 16, 2008 at 17:52 UTC ( [id://730708]=note: print w/replies, xml ) Need Help??


in reply to Perl style/best practice question: how to [better] embed SQL in code ?

my ($sid, $age) = $dbh->selectrow_array(<<'SQL', undef, $uid); SELECT SessionID, datediff(minute, TimeStamp, getdate()) FROM Sessions WHERE UserID = ? AT ISOLATION READ UNCOMMITTED SQL my %data = ( Column1 => $value1, Column2 => $value2, # ... ColumnN => $valueN, ); my $rv = $dbh->do(<<"SQL", undef, values %data); INSERT INTO TableName (@{[ join ', ' keys %data ]}) VALUES ( @{[join ', ', map {'?'} keys %data ]}) SQL
  • Comment on Re: Perl style/best practice question: how to [better] embed SQL in code ?
  • Download Code

Log In?
Username:
Password:

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

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

    No recent polls found