Re: Return Value of a Function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Terry Lee Tucker <terry(at)esc1(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Return Value of a Function
Date: 2004-02-02 18:58:33
Message-ID: 21044.1075748313@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Terry Lee Tucker <terry(at)esc1(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2004-02-02 19:06:38 Re: Select Question
Previous Message Joe Conway 2004-02-02 18:55:11 Re: Return Value of a Function