Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Dynamic Query construct based on argument

by ColonelPanic (Friar)
on Nov 19, 2012 at 08:50 UTC ( #1004486=note: print w/replies, xml ) Need Help??


in reply to Dynamic Query construct based on argument

Well, DBI, Perl's standard way of interfacing with databases, lets you do just that. You can make an SQL statement with parameters that can be set later:

my $dbh = DBI->connect(...connection parameters...); my $get_foo = $dbh->prepare("select foo from table where bar=?"); $get_foo->execute(3); #select foo where bar=3 $get_foo->execute($baz); #select foo where bar=$baz

Perhaps you meant something different by constructing a query. If so, you need to specify what you mean. SQL is a whole programming language in itself.



When's the last time you used duct tape on a duct? --Larry Wall

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1004486]
help
Chatterbox?
[choroba]: i.e. using it for a totally different purpose than it was written for

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2017-11-17 21:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (274 votes). Check out past polls.

    Notices?