Re: PL/pgSQL 'i = i + 1' Syntax

From: "Jaime Casanova" <systemguards(at)gmail(dot)com>
To: "David Wheeler" <david(at)kineticode(dot)com>
Cc: "Andrew Dunstan" <andrew(at)dunslane(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PL/pgSQL 'i = i + 1' Syntax
Date: 2006-05-17 00:51:10
Message-ID: c2d9e70e0605161751t70bb3ccbxfc8362f217695e3b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 5/16/06, David Wheeler <david(at)kineticode(dot)com> wrote:
> On May 16, 2006, at 16:30, Andrew Dunstan wrote:
>
> > It ought to be illegal to modify the loop control variable anyway,
> > IMNSHO - it certainly is in Ada, the distant antecedent of pl/pgsql.
>
> I agree, but I must say that it's incredibly useful to be able to
> increment by two as I go through a loop:
>
> FOR i IN 1 + offset .. 11 + offset LOOP
> total := total + substring(ean, i, 1)::INTEGER;
> i = i + 1;
> END LOOP;
>
> Best,
>
> David
>

i have posted a patch to add a BY clause to the for statement (integer
version), with the BY clause you can specify an increment value...

it's in the unapplied patches list waiting for review...

http://candle.pha.pa.us/mhonarc/patches/msg00003.html

--
regards,
Jaime Casanova

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
Richard Cook

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Wheeler 2006-05-17 02:07:12 Re: PL/pgSQL 'i = i + 1' Syntax
Previous Message Andrew Piskorski 2006-05-17 00:14:34 Re: Compression and on-disk sorting