Re: Obtain boolean value of expression in PLPGSQL - Mailing list pgsql-general

From Martin Hart
Subject Re: Obtain boolean value of expression in PLPGSQL
Date
Msg-id 57780.81.136.181.57.1067944627.squirrel@maxproxy1.uk2net.com
Whole thread Raw
In response to Obtain boolean value of expression in PLPGSQL  (Max Speransky <mx@lucky.net>)
List 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


pgsql-general by date:

Previous
From: "Najib Abi Fadel"
Date:
Subject: Using SUBSELECT in CHECK expressions
Next
From: "Hijax"
Date:
Subject: now() problem