From: | postgres(at)vsservices(dot)com |
---|---|
To: | Randall Perry <rgp(at)systame(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Perl won't eval PgSQL boolean value |
Date: | 2001-09-03 19:27:27 |
Message-ID: | 01090314272700.99384@prime.vsservices.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)VSServices(dot)COM | General Geek
CTHULU for President - Why choose the lesser of two evils?
From | Date | Subject | |
---|---|---|---|
Next Message | Alex Knight | 2001-09-03 19:37:16 | Re: [WAY OT] Re: PL/java? |
Previous Message | Tom Lane | 2001-09-03 19:16:31 | Re: nested SQL with SPI |