Re: Strange behavior of plpgsql.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alex du Plessis <alexdup(dot)main(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Strange behavior of plpgsql.
Date: 2009-11-06 15:02:56
Message-ID: 8325.1257519776@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Alex du Plessis <alexdup(dot)main(at)gmail(dot)com> writes:
> However, it seems that plsql rather has a problem with the double dot i.e.
> NEW.amount.direction and could not parse that (or did not have any knowledge
> of the complex type).

You would have a problem with that with an ordinary table reference,
too, though plpgsql is probably a bit worse about providing a useful
error message :-(. The trick is that you need to parenthesize:
(NEW.amount).direction
With three components in the name, the parser is thinking that it
must be schema.table.column, and NEW isn't a schema name. With
the parentheses in place, the name is correctly resolved as a column
of NEW, and then since it's a composite you can extract a field.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Lush 2009-11-06 15:07:10 how does psql know where to go?
Previous Message Bob McConnell 2009-11-06 12:46:24 Re: SQL Server