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

Re: Fill in SQL from Bind Values

by awohld (Hermit)
on Oct 29, 2013 at 05:26 UTC ( [id://1060110]=note: print w/replies, xml ) Need Help??


in reply to Fill in SQL from Bind Values

This is what I came up with... as elegant as I could think but still feels hackery. But shouldn't there be a way to just get the straight SQL without the bind and placeholder values?
my @sql_char_list = map { my $char = $_; my $wanted = $char eq '?' ? shift @bind : $char; $wanted; } split '', $stmt; $stmt = join "", @sql_char_list; die Dumper $stmt;

Replies are listed 'Best First'.
Re^2: Fill in SQL from Bind Values
by hdb (Monsignor) on Oct 29, 2013 at 09:00 UTC

    Not sure you should be doing it this way, but you can distill your code into:

    $stmt =~ s/\?/shift @bind/ge;

    or with quotes

    $stmt =~ s/\?/"'".(shift @bind)."'"/ge;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-04-19 10:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found