Lists: | pgsql-hackers |
---|
From: | "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | proposal, plpgsql, 8.4, for record in cursor |
Date: | 2007-11-26 15:32:24 |
Message-ID: | 162867790711260732u6a778211s31e29cacb5304b53@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hello
I propose new kind of FOR statement .. iteration over cursor, There
are two reasons:
a) better readability of procedure; - SQL statement is outside of statement,
b) better conformance with PL/SQL.
Sample:
CREATE OR REPLACE FUNCTION foo()
RETURNS void AS $$
DECLARE
c CURSOR(p integer)
FOR SELECT *
FROM foot
WHERE a = p;
BEGIN
FOR r IN c(10) LOOP
RAISE NOTICE '%', r.a;
END LOOP;
RETURN;
END;
$$ FUNCTION plpgsql;
Syntax:
FOR recordvar IN cursor[ ( params ) ] LOOP
..
END LOOP;
Notes:
recordvar is local in statement body (like fori). Used cursor is
automatically opened and closed.
Lot of code can be shared with fors and dynafors (some with stmt_open).
Regards
Pavel Stehule
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: proposal, plpgsql, 8.4, for record in cursor |
Date: | 2007-11-26 15:47:04 |
Message-ID: | 14397.1196092024@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
"Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> writes:
> I propose new kind of FOR statement .. iteration over cursor,
This seems useless and probably syntactically ambiguous.
regards, tom lane
From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> |
Subject: | Re: proposal, plpgsql, 8.4, for record in cursor |
Date: | 2007-11-26 16:31:16 |
Message-ID: | 200711261731.17168.peter_e@gmx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Am Montag, 26. November 2007 schrieb Tom Lane:
> "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> writes:
> > I propose new kind of FOR statement .. iteration over cursor,
>
> This seems useless and probably syntactically ambiguous.
I think that is isomorphic to what he mentioned as "better conformance with
PL/SQL".
--
Peter Eisentraut
http://developer.postgresql.org/~petere/
From: | "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: proposal, plpgsql, 8.4, for record in cursor |
Date: | 2007-11-26 17:06:32 |
Message-ID: | 162867790711260906i1d805987y4a962306d0395ed7@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 26/11/2007, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> writes:
> > I propose new kind of FOR statement .. iteration over cursor,
>
> This seems useless and probably syntactically ambiguous.
>
I don't see any syntactically problem and I have working prototype.
This case is simply identified by cursor variable after IN keyword.
It's possibility little bit clean open, fors, dynafors code.
Regards
Pavel Stehule
regards, tom lane
>
From: | Chris Browne <cbbrowne(at)acm(dot)org> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: proposal, plpgsql, 8.4, for record in cursor |
Date: | 2007-11-26 17:41:20 |
Message-ID: | 60wss4dhvj.fsf@dba2.int.libertyrms.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
peter_e(at)gmx(dot)net (Peter Eisentraut) writes:
> Am Montag, 26. November 2007 schrieb Tom Lane:
>> "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> writes:
>> > I propose new kind of FOR statement .. iteration over cursor,
>>
>> This seems useless and probably syntactically ambiguous.
>
> I think that is isomorphic to what he mentioned as "better conformance with
> PL/SQL".
Hmm. So "better conformance with PL/SQL" amounts to being useless and
syntactically ambiguous...
;-)
--
let name="cbbrowne" and tld="linuxfinances.info" in name ^ "@" ^ tld;;
http://linuxfinances.info/info/sgml.html
"HE'S AHAB, boy; and Ahab of old, thou knowest, was a crowned king!"
-- /Moby-Dick/, Ch 16