pl/pgsql perform and execute return wrong values... - Mailing list pgsql-general

From Alexander Blüm
Subject pl/pgsql perform and execute return wrong values...
Date
Msg-id 23905.1080578447@www23.gmx.net
Whole thread Raw
Responses Re: pl/pgsql perform and execute return wrong values...
List pgsql-general
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


pgsql-general by date:

Previous
From: "Uwe C. Schroeder"
Date:
Subject: Re: PG vs MySQL
Next
From: "Joshua D. Drake"
Date:
Subject: Re: PG vs MySQL