Re: Return Value of a Function - Mailing list pgsql-general

From Tom Lane
Subject Re: Return Value of a Function
Date
Msg-id 21044.1075748313@sss.pgh.pa.us
Whole thread Raw
In response to Re: Return Value of a Function  (Terry Lee Tucker <terry@esc1.com>)
Responses Re: Return Value of a Function  (Terry Lee Tucker <terry@esc1.com>)
List pgsql-general
Terry Lee Tucker <terry@esc1.com> writes:
> My version is: 7.2.3-RH
> Is this my problem?

Probably.  I don't recall the exact state of play of functions returning
rows in 7.2, but certainly Joe Conway has greatly improved it in the
last couple of releases.  You should think about updating to 7.4.

> I'm trying to write a function that will return the last record in a
> sequence of logs, "last" being defined by an ORDER BY statement containing
> time stamp criteria in conjuction with other data. The function would always
> be called by trigger code.

You could try declaring the function to return the specific rowtype of
the log table, rather than the generic RECORD type.  I'm quite certain
generic RECORD didn't do anything useful in 7.2.  But even then, the
most useful way to call it (namely, a function call in SELECT's FROM
clause) wasn't there in 7.2.

Probably what you should do as long as you're on 7.2 is just have the
function determine and return the primary key of the correct log table
entry, and then SELECT using that key in the calling trigger functions.

            regards, tom lane

pgsql-general by date:

Previous
From: Joe Conway
Date:
Subject: Re: Return Value of a Function
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Select Question