Re: ambiguous local variable name in 9.0 proc

From: Samuel Gendler <sgendler(at)ideasculptor(dot)com>
To: David Johnston <polobo(at)yahoo(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: ambiguous local variable name in 9.0 proc
Date: 2011-09-21 23:55:28
Message-ID: CAEV0TzDNpTyOnEdHes3eFOv2Dcs_SHyoPymd=hTYH4dASyS7ug@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, Sep 21, 2011 at 4:49 PM, David Johnston <polobo(at)yahoo(dot)com> wrote:

> ** **
>
> *
> *
>
> Not tested but I think all local variables are implicitly scoped to the
> function name so you should be able to do the following:****
>
> ** **
>
> WHERE reporting_mgmt.aggregate_timescales_impl.tbl_schema = e.tbl_schema**
> **
>
> **
>

Yep. It is also possible to change the db behaviour globally or on a
per-function basis

from
http://developer.postgresql.org/pgdocs/postgres/plpgsql-implementation.html

"To change this behavior on a system-wide basis, set the configuration
parameter plpgsql.variable_conflict to one of error, use_variable, or
use_column(where error is the factory default)."

You can also set the behavior on a function-by-function basis, by inserting
one of these special commands at the start of the function text:

#variable_conflict error
#variable_conflict use_variable

#variable_conflict use_column

Sorry for jumping straight a mailing list query. It was actually relatively
easy to find in the docs. Now to figure out if the function name scoping
trick works in 8.4 so that I can modify my procs prior to upgrading my db.

--sam

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2011-09-22 00:00:50 Re: ambiguous local variable name in 9.0 proc
Previous Message David Johnston 2011-09-21 23:49:05 Re: ambiguous local variable name in 9.0 proc