From 4089d2517560ec2265c42fcf7a786e04207f2787 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 27 Apr 2003 22:21:22 +0000 Subject: Fix plpgsql so that variables of composite types (rowtypes) can be declared without having to write %ROWTYPE. If the declared type of a variable is a composite type, it'll be taken to be a row variable automatically. --- doc/src/sgml/plpgsql.sgml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'doc/src/sgml') diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml index 38306e100b2..2aa0c07ed1b 100644 --- a/doc/src/sgml/plpgsql.sgml +++ b/doc/src/sgml/plpgsql.sgml @@ -1,5 +1,5 @@ @@ -541,7 +541,8 @@ user_id users.user_id%TYPE; Row Types -name tablename%ROWTYPE; +name table_name%ROWTYPE; +name composite_type_name; @@ -550,17 +551,20 @@ user_id users.user_id%TYPE; can hold a whole row of a SELECT or FOR query result, so long as that query's column set matches the declared type of the variable. - tablename must be an existing table or - view name in the database. The individual fields of the row value + The individual fields of the row value are accessed using the usual dot notation, for example rowvar.field. - Presently, a row variable can only be declared using the - %ROWTYPE notation; although one might expect a - bare table name to work as a type declaration, it won't be accepted - within PL/pgSQL functions. + A row variable can be declared to have the same type as the rows of + an existing table or view, by using the + table_name%ROWTYPE + notation; or it can be declared by giving a composite type's name. + (Since every table has an associated datatype of the same name, + it actually does not matter in PostgreSQL whether you + write %ROWTYPE or not. But the form with + %ROWTYPE is more portable.) -- cgit v1.2.3