function param and declared variable of same name - Mailing list pgsql-general

From Sim Zacks
Subject function param and declared variable of same name
Date
Msg-id 4E5F1858.8040207@compulab.co.il
Whole thread Raw
List pgsql-general
<meta http-equiv=3D"content-type" content=3D"text/html; charset=3DISO-8=
859-1">body
      p { margin-bottom: 0cm; margin-top: 0pt; }

  <body style=3D"direction: ltr;"
    bidimailui-detected-decoding-type=3D"latin-charset" bgcolor=3D"#ffffff"
    text=3D"#000000">
    Tested in 8.2 and 9.0.1
    In plpgsql, if you have a function parameter and a variable of the
    same name, it ignores the value passed in and initializes the
    variable to null.
    The correct action, IMO, would be to raise an error.

    create or replace function test1(x int) returns int as
    $$
    declare x int;
    begin
    =A0=A0=A0 return x;
    end;
    $$ language 'plpgsql';

    Thanks
    Sim

pgsql-general by date:

Previous
From: Guillaume Lelarge
Date:
Subject: Re: ERD Tool
Next
From: Sim Zacks
Date:
Subject: Re: function on trigger