Quantcast
Channel: Toad Extension for Eclipse
Viewing all articles
Browse latest Browse all 978

Forum Post: RE: Some problems on TEE and possible workarounds?

$
0
0
Hi Lukas, Maybe this would help you. Here is a script to test the mentioned problems. Run this is any version of PostgreSQL = 9.1 -- create table for testing create table test_table ( id integer  NOT NULL , name VARCHAR (200)  NOT NULL ); -- add some data into created table insert into test_table values (1, 'Row #1'); insert into test_table values (2, 'Row #2'); insert into test_table values (3, 'Row #3'); -- create a function that shows mentioned problems: CREATE OR REPLACE FUNCTION get_setof_refcursors() RETURNS SETOF refcursor AS $BODY$ DECLARE  l_test_var integer;    o_cursor_1 refcursor;  o_cursor_2 refcursor;   BEGIN  UPDATE test_table     SET name = 'UPDATED Row #3'   WHERE id = 3   RETURNING id into l_test_var;      -- get refcursor 1      OPEN o_cursor_1 FOR         SELECT id, name   FROM test_table  WHERE id = l_test_var;      RETURN NEXT o_cursor_1;      -- get refcursor 2      OPEN o_cursor_2 FOR         SELECT id, name   FROM test_table;      RETURN NEXT o_cursor_2;   END; $BODY$ LANGUAGE plpgsql VOLATILE; This function will compile correctly without any warnings. The "RETURNING INTO" clause in the update instruction will effectively return the updated ID into the l_test_var, but TEE parser shows that instruction as an error. If you test this function (with AUTOCOMMIT off), you can only see the first refcursor. The second cursor with all rows from the table is never showed. If you need any more information, just ask, Thanks and regards, CL

Viewing all articles
Browse latest Browse all 978

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>