Trying to safely compare user input name against database

[email protected] ("Larry W. Virden")
Newsgroups perl.dbi.users
Organization http://groups.google.com
Message-ID <b5482d88-0432-4823-8b05-6ba6598a7ad9@z17g2000vbd.googlegroups.com>
I've a case where a function is called with a string provided by a
user, and some legacy code then puts that string into a select
statement for dbi.  The code currently reads:

  my ($query) = $dbconn->prepare(
                "Select * from my_table where last_name LIKE
'$SearchName'");
  $query->execute() or return \@retval; #problem return empty array

Now, one of the issues that comes up is the situation where the user's
string doesn't match the case of the name in the table.

For instance, if they pass a "McDonnel" as the string, but in the
table, it is "Mcdonnel", of course there is no match.

So, I was thinking of modifying this to read

  my ($query) = $dbconn->prepare(
                "Select * from my_table where UPPER(last_name) LIKE
UPPER('$SearchName')");

Are there any gotchas in going this route? Is there a better way of
doing this?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.