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

From Max Speransky
Subject Obtain boolean value of expression in PLPGSQL
Date
Msg-id 20031104100616.GJ64762@lucky.net
Whole thread Raw
Responses Re: Obtain boolean value of expression in PLPGSQL  (Richard Huxton <dev@archonet.com>)
Re: Obtain boolean value of expression in PLPGSQL  (Pavel Stehule <stehule@kix.fsv.cvut.cz>)
Re: Obtain boolean value of expression in PLPGSQL  ("Martin Hart" <zsdfherg@uk2.net>)
List pgsql-general
Hello

My task is to validate expression and get value of it in boolean variable.
I try to do following:
CREATE OR REPLACE FUNCTION get_value(integer) RETURNS boolean AS'
DECLARE
        Ret     boolean;
        Op      TEXT = ''='';
BEGIN

        Ret := 3 || Op || $1;
        RETURN Ret;
END;
' language 'plpgsql';

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'
bill=#

So, how can I explain that resulting type must be boolean ? Also, I try to
play with SELECT INTO with same result.

--
... All opinions expressed are mine and not those of my employer.

Yours, Max                 [Msg N 2419]
-------------------------------------------
mailto: mx@lucky.net phone: +380-44-2054455

pgsql-general by date:

Previous
From: Ang Chin Han
Date:
Subject: Re: Please help
Next
From: Alex
Date:
Subject: SELECT question