stored queries and quoted strings

Поиск
Список
Период
Сортировка
От filippo
Тема stored queries and quoted strings
Дата
Msg-id 1175239878.580307.28090@o5g2000hsb.googlegroups.com
обсуждение исходный текст
Ответы Re: stored queries and quoted strings
Список pgsql-general
Hello,

I have a strange problem with stored queries like this

  $sql = qq/
         SELECT city, country
         FROM countries
         WHERE city LIKE ?
         ORDER BY city
           /;
  $sthCity= $dbh->prepare($sql);
  my $tempCity = $dbh->quote("n%");
  $sthCity->execute($tempCity);
  my $result = $sthCity->fetchall_arrayref;

the query doesn't return any value. It works only if I remove the -
>quote(). The following code actually works retuning all cities with
their name n-something

  my $tempCity = "n%";
  $sthCity->execute($tempCity);
  my $result = $sthCity->fetchall_arrayref;

bu I'm a little bit worried to use a a WHERE statement without quoting
the search pattern (input by user). Is it a problem or not?

Thanks,

Filippo


В списке pgsql-general по дате отправления:

Предыдущее
От: Lew
Дата:
Сообщение: Re: coalesce for null AND empty strings
Следующее
От: RPK
Дата:
Сообщение: Wrong increments of Sequence