Re: PL/pgSQL 'i = i + 1' Syntax - Mailing list pgsql-hackers

From Albe Laurenz
Subject Re: PL/pgSQL 'i = i + 1' Syntax
Date
Msg-id 52EF20B2E3209443BC37736D00C3C1380876BDC7@EXADV1.host.magwien.gv.at
Whole thread Raw
In response to PL/pgSQL 'i = i + 1' Syntax  (David Wheeler <david@kineticode.com>)
Responses Re: PL/pgSQL 'i = i + 1' Syntax  ("Andrew Dunstan" <andrew@dunslane.net>)
List pgsql-hackers
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.

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?

Yours,
Laurenz Albe


pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: audit table containing Select statements submitted
Next
From: "Gurjeet Singh"
Date:
Subject: Re: audit table containing Select statements submitted