Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Re: Fast Building of SQL Statements

by DapperDan (Pilgrim)
on Aug 28, 2003 at 12:36 UTC ( [id://287334]=note: print w/replies, xml ) Need Help??


in reply to Re: Fast Building of SQL Statements
in thread Fast Building of SQL Statements

++. This is the best one, for my money.

Very readable, and probably could be pulled out to a general sub which generates the run_insert sub for you. Nice use of a closure as well. I like this a lot as its a piece of code I have written badly over and over.

(Rushing back to work after lunch, so not doing it myself (yet).)

  • Comment on Re: Re: Fast Building of SQL Statements

Replies are listed 'Best First'.
Re^3: Fast Building of SQL Statements
by Aristotle (Chancellor) on Aug 28, 2003 at 12:59 UTC
    Yep, that's easy.
    sub make_insert_func { my @PLACEHOLDERS = ('?') x @_; local $" = ','; my $SQL = "INSERT (@_) INTO foo VALUES (@PLACEHOLDERS)"; return sub { my $dbh = shift || return; my $sth = $dbh->prepare($SQL); $sth->execute(@_); $sth->finish; } }

    Makeshifts last the longest.

Log In?
Username:
Password:

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

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

    No recent polls found