Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteeb1dd5

Browse files
committed
On Wed, 2002-05-29 at 01:41, Tom Lane wrote:
>> > Is it a good idea to provide an example (such as the above), or should I> > just try and describe the behaviour?>> Examples are generally good things ...OK, the attached documentation patch provides some simple examples ofuse of tablename as a parameter, %ROWTYPE and %TYPE.In the end I decided that the documentation is literally correct, buthard to follow without any examples explicitly showing the use of atable name as a parameter.Andrew McMillan
1 parent240de61 commiteeb1dd5

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

‎doc/src/sgml/plsql.sgml‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/plsql.sgml,v 2.58 2002/05/03 04:11:07 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/plsql.sgml,v 2.59 2002/06/15 19:34:51 momjian Exp $
33
-->
44

55
<chapter id="plpgsql">
@@ -371,6 +371,9 @@ END;
371371
user_id INTEGER;
372372
quantity NUMERIC(5);
373373
url VARCHAR;
374+
myrow tablename%ROWTYPE;
375+
myfield tablename.fieldname%TYPE;
376+
arow RECORD;
374377
</programlisting>
375378
</para>
376379

@@ -448,6 +451,15 @@ BEGIN
448451
-- Some computations here
449452
END;
450453
' LANGUAGE 'plpgsql';
454+
455+
456+
CREATE FUNCTION use_many_fields(tablename) RETURNS TEXT AS '
457+
DECLARE
458+
in_t ALIAS FOR $1;
459+
BEGIN
460+
RETURN in_t.f1 || in_t.f3 || in_t.f5 || in_t.f7;
461+
END;
462+
' LANGUAGE 'plpgsql';
451463
</programlisting>
452464
</para>
453465
</sect2>
@@ -491,6 +503,17 @@ END;
491503
row could be from a view). The fields of the row type inherit the
492504
table's field size or precision for data types such as
493505
<type>char(n)</type>.
506+
<programlisting>
507+
CREATE FUNCTION use_two_tables(tablename) RETURNS TEXT AS '
508+
DECLARE
509+
in_t ALIAS FOR $1;
510+
use_t table2name%ROWTYPE;
511+
BEGIN
512+
SELECT * INTO use_t FROM table2name WHERE ... ;
513+
RETURN in_t.f1 || use_t.f3 || in_t.f5 || use_t.f7;
514+
END;
515+
' LANGUAGE 'plpgsql';
516+
</programlisting>
494517
</para>
495518
</sect2>
496519

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp