Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Dynamic SQL

by Your Mother (Archbishop)
on Apr 06, 2015 at 16:30 UTC ( [id://1122578]=note: print w/replies, xml ) Need Help??


in reply to Dynamic SQL

Your code seems very badly organized if you can really mix into a single line of execution like that. You might look at refactoring the design. That said, caching the cached statements yourself is trivial with Perl–

my %query_map; # Actually declared in higher (more outer) scope. if ( $x > 10 ) { $query = "SELECT Name FROM Customers WHERE CustId = ?"; } else { $query = "SELECT Name FROM Sales WHERE SalesId = ?"; } $query_map{$query} ||= $dbh->prepare($query); $query_map{$query}->execute(@args_that_will_match_query);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-26 00:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found