[prev in list] [next in list] [prev in thread] [next in thread]
List: postgresql-general
Subject: Re: Strange behavior with missing column in SQL function
From: Marcelo Lacerda <marceloslacerda () gmail ! com>
Date: 2018-07-31 22:13:28
Message-ID: CAPmRTtOL3mNGf-0MwwAWJjmc=WJo0Y7QDc0R2AOhSkPQ=i_KEg () mail ! gmail ! com
[Download RAW message or body]
> CREATE OR REPLACE FUNCTION myfunction(myrow mytable)
> RETURNS INTEGER AS $$
> SELECT myrow.c + myrow.b FROM myrow;
> $$ LANGUAGE sql;
> where "myrow" is a table with a different set of column names from
> "mytable". The existing behavior for that is to seek the column name
> in "myrow" (the table), failing that to seek it in the parameter,
> and only to throw an error if both fail.
Wow I never thought this would be possible. why didn't the designers of the
language use myrow mytable%ROWTYPE for rows of a table as a parameter,
given that it's a valid type in PL/PGSQL? I figure that way it would have
been way easier to disambiguate the definitions.
[Attachment #3 (text/html)]
<div dir="ltr">> CREATE OR REPLACE FUNCTION myfunction(myrow mytable)<br>
> RETURNS INTEGER AS $$<br>
> SELECT myrow.c + myrow.b FROM myrow;<br>
> $$ LANGUAGE sql;<br>
<br>
> where "myrow" is a table with a different set of column names from<br>
> "mytable". The existing behavior for that is to seek the column \
name<br> > in "myrow" (the table), failing that to seek it in the \
parameter,<br> > and only to throw an error if both fail.<br><div></div><div>Wow I \
never thought this would be possible. why didn't the designers of the language \
use myrow mytable%ROWTYPE for rows of a table as a parameter, given that it's a \
valid type in PL/PGSQL? I figure that way it would have been way easier to \
disambiguate the definitions.<br></div></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic