in reply to Problem constructing an SQL query with LIKE clauses
If your script is for general consumption, I hope you're using -T and are untainting $SQLCommand. Otherwise, someone can slip something truly evil into your SQL stream.
I recommend that you use bind variables in the query, like
Then, when you execute the prepared query, you can wrap the variables. You'll need some logic to do it, so that you don't end up with '%%' if the variable is "". I do something like$SQLCommand = <<SQL; SELECT Client, Product, License, Issue, Data, Id, Call FROM support WHERE Client LIKE ? AND Product LIKE ? AND Issue LIKE ? AND Cause LIKE ? AND Call LIKE ? AND SupportDetails LIKE ? SQL
I'll leave like_arg() as an exercise.$sth->execute(like_arg(1, $Client, 1), ... etc ... );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Passing data from one perl script to another.
by sdyates (Scribe) on Apr 17, 2002 at 00:49 UTC | |
by dws (Chancellor) on Apr 17, 2002 at 03:53 UTC | |
|
Re: Re: Passing data from one perl script to another.
by sdyates (Scribe) on Apr 17, 2002 at 01:46 UTC |