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

From: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
To: <all(at)adv(dot)magwien(dot)gv(dot)at>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PL/pgSQL 'i = i + 1' Syntax
Date: 2006-05-17 10:40:38
Message-ID: 2447.24.211.165.134.1147862438.squirrel@www.dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Albe Laurenz said:
> Tom Lane 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.
>>
>> If modifying the loop variable is disallowed in PL/SQL, I'm all for
>> disallowing it in plpgsql, otherwise not. Anyone have a
>> recent copy of Oracle to try it on?
>
> I tried this on Oracle 10.2.0.2.0 (which is the most recent version):
>
> SET SERVEROUTPUT ON
> BEGIN
> FOR i IN 1..10 LOOP
> i := i + 1;
> DBMS_OUTPUT.PUT_LINE(i);
> END LOOP;
> END;
> /
> i := i + 1;
> *
> ERROR at line 3:
> ORA-06550: line 3, column 7:
> PLS-00363: expression 'I' cannot be used as an assignment target
> ORA-06550: line 3, column 7:
> PL/SQL: Statement ignored
>
> And the documentation also explicitly states that it is not allowed.
>

So should we if it can be done conveniently. That might be a big IF - IIRC
many Pascal compilers ignore the similar language rule because implementing
it is a pain in the neck.

> By the way, PL/SQL screams if you want to do an assignment with '='.
> But I guess that the current behaviour of PL/pgSQL should not reflect
> that to maintain backward compatibility, right?
>

I think it should. The current behaviour is undocumented and more than icky.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2006-05-17 11:10:07 Re: Compression and on-disk sorting
Previous Message Robert Watson 2006-05-17 10:37:49 Re: semaphore usage "port based"?