diff --git a/doc/src/sgml/plsql.sgml b/doc/src/sgml/plsql.sgml index b360e91f5c..91e96c77f0 100644 --- a/doc/src/sgml/plsql.sgml +++ b/doc/src/sgml/plsql.sgml @@ -1,5 +1,5 @@ @@ -371,6 +371,9 @@ END; user_id INTEGER; quantity NUMERIC(5); url VARCHAR; +myrow tablename%ROWTYPE; +myfield tablename.fieldname%TYPE; +arow RECORD; @@ -448,6 +451,15 @@ BEGIN -- Some computations here END; ' LANGUAGE 'plpgsql'; + + +CREATE FUNCTION use_many_fields(tablename) RETURNS TEXT AS ' +DECLARE + in_t ALIAS FOR $1; +BEGIN + RETURN in_t.f1 || in_t.f3 || in_t.f5 || in_t.f7; +END; +' LANGUAGE 'plpgsql'; @@ -491,6 +503,17 @@ END; row could be from a view). The fields of the row type inherit the table's field size or precision for data types such as char(n). + +CREATE FUNCTION use_two_tables(tablename) RETURNS TEXT AS ' +DECLARE + in_t ALIAS FOR $1; + use_t table2name%ROWTYPE; +BEGIN + SELECT * INTO use_t FROM table2name WHERE ... ; + RETURN in_t.f1 || use_t.f3 || in_t.f5 || use_t.f7; +END; +' LANGUAGE 'plpgsql'; +