Re: Return Value of a Function

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Return Value of a Function
Дата
Msg-id 21044.1075748313@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Return Value of a Function  (Terry Lee Tucker <terry@esc1.com>)
Ответы Re: Return Value of a Function  (Terry Lee Tucker <terry@esc1.com>)
Список 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 по дате отправления:

Предыдущее
От: Joe Conway
Дата:
Сообщение: Re: Return Value of a Function
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Select Question