Re: Obtain boolean value of expression in PLPGSQL

From: "Martin Hart" <zsdfherg(at)uk2(dot)net>
To: "Max Speransky" <mx(at)lucky(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Obtain boolean value of expression in PLPGSQL
Date: 2003-11-04 11:17:07
Message-ID: 57780.81.136.181.57.1067944627.squirrel@maxproxy1.uk2net.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Max Speransky said:
> Hello
>
> My task is to validate expression and get value of it in boolean variable.
[snip]
> when I try to execute this function I get such result:
>
> bill=# select get_value(3);
> WARNING: Error occurred while executing PL/pgSQL function get_value
> WARNING: line 6 at assignment
> ERROR: Bad boolean external representation '3=3'

|| is the string concatenation operator - so your expression creates a
string "3=3" and then tries to return that as a boolean hence the error.

if you cannot just do "return 3 = $1;" perhaps you could try using EXECUTE?

cheers
Martin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rob Fielding 2003-11-04 11:21:35 pg7.3.4: pg_atoi: zero-length string
Previous Message Richard Huxton 2003-11-04 11:14:14 Re: SELECT question