Re: unique names in variables and columns in plsql functions

From: Wiebe Cazemier <halfgaar(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: unique names in variables and columns in plsql functions
Date: 2006-03-27 21:39:04
Message-ID: 44285B78.8010804@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

(Whoops, pressed wrong reply button. Here it is correctly this time.)

On 03/27/06 17:02, Tom Lane wrote:

>It'll retrieve whatever the current value of the plpgsql variable
>provider_id is. plpgsql always assumes that ambiguous names refer
>to its variables (indeed, it isn't even directly aware that there's
>any possible ambiguity here).
>
>
That's why I suspected it would be NULL, since provider_id wasn't
initialised yet.

>
>How and why would it determine that? In general it's perfectly normal
>to use plpgsql variable values in SQL commands. I don't think it'd make
>the system more usable if the parser tried to apply a heuristic rule
>about some occurrences being meant as variable references and other ones
>not. If the rule ever got it wrong, it'd be even more confusing.
>
I guess I'm looking at it too much as a human. I said "SELECT FROM" so,
it guess I assumed it would be clear enough which one it had to use.
But, now that I'm thinking about it some more, I agree. However, a fatal
error would also have been welcome.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Maciej Piekielniak 2006-03-27 23:35:31 cursor and for update
Previous Message Wiebe Cazemier 2006-03-27 21:38:27 Re: unique names in variables and columns in plsql functions