Hello

Now, statements EXECUTE INTO and SELECT INTO allow using list of scalars.
FORe and FORs allow only ROW o RECORD VARIABLE. I'll plan and I did it
enhance this stmts:

<for> := FOR <target> IN {SELECT | EXECUTE} ... LOOP
<target> := {row|record|comma separated list of scalar vars}

<assign> := <target2> ':=' <expression>
<target2> := {row|record|variable|'ROW(' comma separated list of scalar vars
')'}

for example:
CREATE OR REPLACE FUNCTION test(OUT _rc, OUT _x varchar, OUT _y varchar)
RETURNS SETOF RECORD AS $$
DECLARE _r RECORD;
BEGIN
rc := 0;
-- old style;
FOR _r IN SELECT generate_series AS x, generateseries + 1 AS y FROM
generate_series(1,4) LOOP
_rc := _rc + 1; _x := _r.x; _y := _r.y;
RETURN NEXT;
END LOOP;
-- new one
FOR _x,_y IN SELECT generate_series, generateseries + 1 FROM
generate_series(1,4) LOOP
_rc := _rc + 1;
RETURN NEXT;
END LOOP;
-- new two
FOR _r IN SELECT generate_series AS x, generateseries + 1 AS y FROM
generate_series(1,4) LOOP
_rc := _rc + 1; ROW(_x,_y) := _r;
RETURN NEXT;
END LOOP;
RETURN;
END; $$ LANGUAGE plpgsql;

any comments?
Regards
Pavel Stehule

_________________________________________________________________
Najdete si svou lasku a nove pratele na Match.com. http://www.msn.cz/

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 5 | next ›
Discussion Overview
grouppgsql-hackers @
categoriespostgresql
postedDec 22, '05 at 9:18a
activeDec 22, '05 at 11:53p
posts5
users4
websitepostgresql.org...
irc#postgresql

People

Translate

site design / logo © 2021 Grokbase