Обсуждение: In plpgsql: difference between := and =

Поиск
Список
Период
Сортировка

In plpgsql: difference between := and =

От
David
Дата:
I know I've seen this somewhere, but I've searched the docs and can't
seem to find it.

I know that := is assignment, and, from the docs, (and experience),
know that it does a "SELECT" to return the assigned value.

I was experimenting with triggers, in the body, I was trying something
like:

BEGIN
   NEW.name := get_who(NEW.name);
   RETURN NEW;
END

where get_who() is a stored procedure.

After going through some of my pgsql- mail-archives, I saw a similar
example where they used simply "=".

After I did this, it worked.

Could someone explain the why's and the difference?  I know I've seen
this explained before, but where, I don't know...

Re: In plpgsql: difference between := and =

От
Tom Lane
Дата:
David <dbree@duo-county.com> writes:
> Could someone explain the why's and the difference?

There is no difference between := and = in plpgsql: the scanner treats
them as the same token.  You didn't show us your problem in any detail,
but I'll bet you made some other change that fixed whatever was
bothering you.

            regards, tom lane

Re: In plpgsql: difference between := and =

От
David
Дата:
On Wed, Apr 12, 2006 at 08:43:20PM -0400, Tom Lane wrote:
> David <dbree@duo-county.com> writes:
> > Could someone explain the why's and the difference?

> There is no difference between := and = in plpgsql: the scanner treats
> them as the same token.  You didn't show us your problem in any detail,
> but I'll bet you made some other change that fixed whatever was
> bothering you.

Well.. I went back and recreated a new setup and sure enough.. this
time, it works both ways..  I dunno what I did.. I could almost have
sworn that the only thing I did was delete the ":" when it began
working.

I can almost picture seeing the statement that you _must_ use ":=" in a
variable assignment, and that there was a difference, but apparently I
dreamed it or it's a fact in some other application..  This belief was
what prompted the question.

Sorry for the noise, and thanks for the reply setting this straight.

Re: In plpgsql: difference between := and =

От
Tom Lane
Дата:
David <dbree@duo-county.com> writes:
> On Wed, Apr 12, 2006 at 08:43:20PM -0400, Tom Lane wrote:
>> There is no difference between := and = in plpgsql: the scanner treats
>> them as the same token.

> I can almost picture seeing the statement that you _must_ use ":=" in a
> variable assignment, and that there was a difference, but apparently I
> dreamed it or it's a fact in some other application.

I think that only the := variant is shown in the documentation, but they
work the same.

            regards, tom lane