Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Argument problem when using a perl script

by graff (Chancellor)
on Apr 12, 2016 at 22:28 UTC ( [id://1160268]=note: print w/replies, xml ) Need Help??


in reply to Re: Argument problem when using a perl script
in thread Argument problem when using a perl script

Note that if a valid/actionable return from  $oracle_connector->opts->condition could be the string "0", then we wouldn't want this to evaluate to false (and skip the "where" clause). Also, in case the return from that function call might contain an apostrophe, we'd want to use a placeholder for the value in the SQL statement:
my $condition = $oracle_connector->opts->condition; my @bind_values = (); my $where = ""; if ( $condition =~ /\S/ ) { push @bind_values, $condition; $where = " WHERE status = ?"; } my $sth = $db->prepare("SELECT COUNT(*) from CONNECTOR.$table$where"); $sth->execute( @bind_values ); # works as intended if @bind_values is + empty
(updated code to add missing sigil)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-03-29 00:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found