function accepting a row

Started by Tomek Grzejszczykover 20 years ago5 messagesgeneral
Jump to latest
#1Tomek Grzejszczyk
tgrzej@aster.pl

Hi,
I'am trying to create a function in plpgsql that will accept a parameter
of type rowtype. Here is a little test script I wrote:
http://62.121.81.182/pub/test_func.sql

It works on Postgres 8.03, but fails on 7.4, where I actually want it to
work. What am I doing wrong? Error message says that there is no such
column "row", but it doesn't help me much understanding the problem.

Thanks for help,
Tomek Grzejszczyk

#2Michael Fuhr
mike@fuhr.org
In reply to: Tomek Grzejszczyk (#1)
Re: function accepting a row

On Wed, Aug 10, 2005 at 08:01:13PM +0200, Tomek Grzejszczyk wrote:

I'am trying to create a function in plpgsql that will accept a parameter
of type rowtype. Here is a little test script I wrote:
http://62.121.81.182/pub/test_func.sql

It works on Postgres 8.03, but fails on 7.4, where I actually want it to
work. What am I doing wrong?

Wanting it to work isn't going to change the fact that 8.0 has better
support for composite types than previous versions. See the 8.0 Release
Notes:

http://www.postgresql.org/docs/8.0/static/release-8-0.html

One of the items under "Server-Side Language Changes" is:

* More support for composite types (row and record variables) in PL/pgSQL

For example, it now works to pass a rowtype variable to another
function as a single variable.

If you're using a version older than 8.0 then you'll have to work
within its limitations.

--
Michael Fuhr

#3Tomek Grzejszczyk
tgrzej@aster.pl
In reply to: Michael Fuhr (#2)
Re: function accepting a row

Od: Michael Fuhr <mike@fuhr.org>
..

* More support for composite types (row and record variables) in
PL/pgSQL

For example, it now works to pass a rowtype variable to another
function as a single variable.

If you're using a version older than 8.0 then you'll have to work
within its limitations.

Thanks for the answer,
I tried to follow #37.1.2 from:
http://www.postgresql.org/docs/7.4/interactive/plpgsql.html

where one can read:
"Functions written in PL/pgSQL can accept as arguments any scalar or
array data type supported by the server, and they can return a result
of any of these types. They can also accept or return any composite
type (row type) specified by name."

So is this part of documentation non correct or is my way of calling a
function accepting a rowtype is not correct?

Tomek Grzejszczyk

#4Michael Fuhr
mike@fuhr.org
In reply to: Tomek Grzejszczyk (#3)
Re: function accepting a row

On Thu, Aug 11, 2005 at 12:20:17PM +0200, tgrzej wrote:

I tried to follow #37.1.2 from:
http://www.postgresql.org/docs/7.4/interactive/plpgsql.html

where one can read:
"Functions written in PL/pgSQL can accept as arguments any scalar or
array data type supported by the server, and they can return a result
of any of these types. They can also accept or return any composite
type (row type) specified by name."

So is this part of documentation non correct or is my way of calling a
function accepting a rowtype is not correct?

PL/pgSQL functions can *accept* these types of arguments, but in
versions earlier than 8.0 they have trouble *passing* such arguments
to another function. The documentation should probably be more clear
about that.

--
Michael Fuhr

#5Tomek Grzejszczyk
tgrzej@aster.pl
In reply to: Michael Fuhr (#4)
Re: function accepting a row

Michael Fuhr napisal(a):

PL/pgSQL functions can *accept* these types of arguments, but in
versions earlier than 8.0 they have trouble *passing* such arguments
to another function.

Now I get it. Thank you.

Tomek Grzejszczyk