On Tuesday 04 November 2003 10:06, Max Speransky wrote:
> Hello
>
> My task is to validate expression and get value of it in boolean variable.
> I try to do following:
> Ret := 3 || Op || $1;
> RETURN Ret;
> 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'
The problem is that your expression is being evaluated as a string. In the
absence of an eval() function, you probably should do something like:
my_stmt := ''SELECT '' || 3 || Op || $1;
EXECUTE my_stmt;
FOR EACH ...
So - build a simple query, execute it and read the result. Should do what you
want.
--
Richard Huxton
Archonet Ltd