Re: Perl won't eval PgSQL boolean value
От | postgres@vsservices.com |
---|---|
Тема | Re: Perl won't eval PgSQL boolean value |
Дата | |
Msg-id | 01090314272700.99384@prime.vsservices.com обсуждение исходный текст |
Ответ на | Perl won't eval PgSQL boolean value (Randall Perry <rgp@systame.com>) |
Список | pgsql-general |
On Sunday 02 September 2001 19:01, Randall Perry wrote: > I've got an if statement that checks if a boolean value is true: > > if ($cust_data->{'hold'} eq 't') > > But perl will not evaluate the value. $cust_data->{'hold'} is taken from a > PgSQL boolean field (either t or f). If I use the construct above it tell > me that 'eq' is not defined thinking it's a string. This should work just fine. It sounds like a quote is being dropped somewhere... I just tested it here and it works just fine. > If I use: > if ($cust_data->{'hold'} == 't') > > I get an error saying $cust_data->{'hold'} is a non-numeric value. Which is what it should do. '==' is for numerics only. > If I do this: > if ($cust_data->{'hold'}) > > it will always evaluate to true whether the value is 't' or 'f'. Again, what it should do, both 't' and 'f' are non-zero as far as Perl is concerned. > > HELP. How do you evaluate boolean values from PgSQL in Perl? Your first choice (value eq 't') should do the trick. However, it sounds like there is another problem interfering with it. Could we see the code? GB -- GB Clark II | Roaming FreeBSD Admin gclarkii@VSServices.COM | General Geek CTHULU for President - Why choose the lesser of two evils?
В списке pgsql-general по дате отправления: