Unix Technical Forum

proposal, plpgsql, 8.4, for record in cursor

This is a discussion on proposal, plpgsql, 8.4, for record in cursor within the pgsql Hackers forums, part of the PostgreSQL category; --> Hello I propose new kind of FOR statement .. iteration over cursor, There are two reasons: a) better readability ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-15-2008, 10:34 PM
Pavel Stehule
 
Posts: n/a
Default proposal, plpgsql, 8.4, for record in cursor

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

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-15-2008, 10:34 PM
Tom Lane
 
Posts: n/a
Default Re: proposal, plpgsql, 8.4, for record in cursor

"Pavel Stehule" <pavel.stehule@gmail.com> writes:
> I propose new kind of FOR statement .. iteration over cursor,


This seems useless and probably syntactically ambiguous.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-15-2008, 10:34 PM
Peter Eisentraut
 
Posts: n/a
Default Re: proposal, plpgsql, 8.4, for record in cursor

Am Montag, 26. November 2007 schrieb Tom Lane:
> "Pavel Stehule" <pavel.stehule@gmail.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/

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-15-2008, 10:34 PM
Pavel Stehule
 
Posts: n/a
Default Re: proposal, plpgsql, 8.4, for record in cursor

On 26/11/2007, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Pavel Stehule" <pavel.stehule@gmail.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
>


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-15-2008, 10:34 PM
Chris Browne
 
Posts: n/a
Default Re: proposal, plpgsql, 8.4, for record in cursor

peter_e@gmx.net (Peter Eisentraut) writes:
> Am Montag, 26. November 2007 schrieb Tom Lane:
>> "Pavel Stehule" <pavel.stehule@gmail.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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:31 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com