Suggested patch to plpgsql docs (7.4beta)

Started by Richard Huxtonover 22 years ago6 messagesdocs
Jump to latest
#1Richard Huxton
dev@archonet.com

Addition of one paragraph to the end of section 39.7.3.4 "FOR (integer
variant)"

Note that this is basically a WHILE loop, so if the lower bound is larger than
the upper bound the loop never executes it's contents:
FOR i IN 10..1 LOOP
RAISE NOTICE ''I do not raise a notice %'',i;
END LOOP;

I wasn't sure and had to check, so I assume others might find this useful too.
--
Richard Huxton
Archonet Ltd

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Richard Huxton (#1)
Re: Suggested patch to plpgsql docs (7.4beta)

Richard Huxton writes:

Addition of one paragraph to the end of section 39.7.3.4 "FOR (integer
variant)"

Note that this is basically a WHILE loop, so if the lower bound is larger than
the upper bound the loop never executes it's contents:

I've added a note to this effect. Thanks.

--
Peter Eisentraut peter_e@gmx.net

#3Bruce Momjian
bruce@momjian.us
In reply to: Richard Huxton (#1)
Re: Suggested patch to plpgsql docs (7.4beta)

Richard Huxton wrote:

Addition of one paragraph to the end of section 39.7.3.4 "FOR (integer
variant)"

Note that this is basically a WHILE loop, so if the lower bound is larger than
the upper bound the loop never executes it's contents:
FOR i IN 10..1 LOOP
RAISE NOTICE ''I do not raise a notice %'',i;
END LOOP;

I wasn't sure and had to check, so I assume others might find this useful too.

I figured everyone would assume that. I know of no language that will
execute a loop listed as 10 ... 1.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#4Philip Yarra
philip@utiba.com
In reply to: Bruce Momjian (#3)
Re: Suggested patch to plpgsql docs (7.4beta)

On Thu, 4 Sep 2003 09:11 am, Bruce Momjian wrote:

Richard Huxton wrote:

Addition of one paragraph to the end of section 39.7.3.4 "FOR (integer
variant)"

Note that this is basically a WHILE loop, so if the lower bound is larger
than the upper bound the loop never executes it's contents:
FOR i IN 10..1 LOOP
RAISE NOTICE ''I do not raise a notice %'',i;
END LOOP;

I wasn't sure and had to check, so I assume others might find this useful
too.

I figured everyone would assume that. I know of no language that will
execute a loop listed as 10 ... 1.

Basic on my first computer suppported it, though the syntax was

FOR $i in 10 TO 1 STEP -1
PRINT $i
NEXT

I think it is worth stating explicitly. The apostrophe in "it's" is incorrect
though.

Regards, Philip Yarra.

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#3)
Re: Suggested patch to plpgsql docs (7.4beta)

Bruce Momjian <pgman@candle.pha.pa.us> writes:

I figured everyone would assume that. I know of no language that will
execute a loop listed as 10 ... 1.

Fortran N for N < something-or-other. I think Richard is betraying
his age ;-)

regards, tom lane

#6Richard Huxton
dev@archonet.com
In reply to: Tom Lane (#5)
Re: Suggested patch to plpgsql docs (7.4beta)

On Thursday 04 September 2003 04:32, Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

I figured everyone would assume that. I know of no language that will
execute a loop listed as 10 ... 1.

I did assume that, then my paranoia kicked in suggesting it might be
constructing a list of values and stepping through them. The only reason I
could think it should behave like a while loop is that, well, all the others
do.

Fortran N for N < something-or-other. I think Richard is betraying
his age ;-)

And how DARE you Tom - I clearly meant DotJavaWebSysNet or something trendy
like that and not some crufty version of BASIC from my 6502 days....;-)

--
Richard Huxton
Archonet Ltd