Thread: pl/pgsql perform and execute return wrong values...

pl/pgsql perform and execute return wrong values...

From
"Alexander Blüm"
Date:
CREATE OR REPLACE FUNCTION testifinserted(text) RETURNS bool AS '
DECLARE
        testtext ALIAS FOR $1;
        anfr text;
BEGIN
        anfr := ''SELECT bla FROM testtabelle WHERE bla = '' ||
quote_literal(testtext);
        RAISE NOTICE ''%'', anfr;   -- to show the request
        EXECUTE anfr;
        IF FOUND THEN
                RAISE NOTICE ''jupp, % gefunden in testtabelle'', testtext;
                RETURN true;
        ELSE
                RETURN false;
        END IF;
END;
' LANGUAGE plpgsql;

test=> SELECT * FROM testtabelle;
bla
-----
muh
(1 row)

test=> SELECT testifinserted('muh');
NOTICE:  SELECT bla FROM testtabelle WHERE bla = 'muh'
testifinserted
----------------
f
(1 row)


------------------------------------
WHY ????

seems like PERFORM always returns TRUE and EXECUTE always FALSE...

--
+++ NEU bei GMX und erstmalig in Deutschland: TÜV-geprüfter Virenschutz +++
100% Virenerkennung nach Wildlist. Infos: http://www.gmx.net/virenschutz


Re: pl/pgsql perform and execute return wrong values...

From
Tom Lane
Date:
=?ISO-8859-1?Q?=22Alexander_Bl=FCm=22?= <mailinglists1@gmx.de> writes:
> seems like PERFORM always returns TRUE and EXECUTE always FALSE...

EXECUTE does not affect FOUND.  This is per documentation.

            regards, tom lane