[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">&gt; CREATE OR REPLACE FUNCTION myfunction(myrow mytable)<br>
&gt; RETURNS INTEGER AS $$<br>
&gt;       SELECT myrow.c + myrow.b FROM myrow;<br>
&gt; $$ LANGUAGE sql;<br>
<br>
&gt; where &quot;myrow&quot; is a table with a different set of column names from<br>
&gt; &quot;mytable&quot;.   The existing behavior for that is to seek the column \
name<br> &gt; in &quot;myrow&quot; (the table), failing that to seek it in the \
parameter,<br> &gt; and only to throw an error if both fail.<br><div></div><div>Wow I \
never thought this would be possible. why didn&#39;t the designers of the language \
use myrow mytable%ROWTYPE for rows of a table as a parameter, given that it&#39;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