|
1 | 1 | <!--
|
2 |
| -$PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.93 2005/01/0722:40:46 tgl Exp $ |
| 2 | +$PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.94 2005/01/0723:08:44 tgl Exp $ |
3 | 3 | -->
|
4 | 4 |
|
5 | 5 | <sect1 id="xfunc">
|
@@ -450,6 +450,31 @@ SELECT name(emp) AS youngster FROM emp WHERE age(emp) < 30;
|
450 | 450 | </screen>
|
451 | 451 | </para>
|
452 | 452 |
|
| 453 | + <tip> |
| 454 | + <para> |
| 455 | + The equivalence between functional notation and attribute notation |
| 456 | + makes it possible to use functions on composite types to emulate |
| 457 | + <quote>computed fields</>. |
| 458 | + <indexterm> |
| 459 | + <primary>computed field</primary> |
| 460 | + </indexterm> |
| 461 | + <indexterm> |
| 462 | + <primary>field</primary> |
| 463 | + <secondary>computed</secondary> |
| 464 | + </indexterm> |
| 465 | + For example, using the previous definition |
| 466 | + for <literal>double_salary(emp)</>, we can write |
| 467 | + |
| 468 | +<screen> |
| 469 | +SELECT emp.name, emp.double_salary FROM emp; |
| 470 | +</screen> |
| 471 | + |
| 472 | + An application using this wouldn't need to be directly aware that |
| 473 | + <literal>double_salary</> isn't a real column of the table. |
| 474 | + (You can also emulate computed fields with views.) |
| 475 | + </para> |
| 476 | + </tip> |
| 477 | + |
453 | 478 | <para>
|
454 | 479 | Another way to use a function returning a row result is to pass the
|
455 | 480 | result to another function that accepts the correct row type as input:
|
|