Selecting from a function(x,y) returning a row-type(sum, prod)

Поиск
Список
Период
Сортировка
От Heiko Klein
Тема Selecting from a function(x,y) returning a row-type(sum, prod)
Дата
Msg-id 4635F2EE.3040306@gmx.net
обсуждение исходный текст
Ответы Re: Selecting from a function(x,y) returning a row-type(sum, prod)
Список pgsql-general
Hi,

I'm trying to select data from a table, converting two values and return
all four. Maybe this is best explained with an example:

The function from the documentation on pl/pgsql:

CREATE FUNCTION sum_n_product(x int, y int, OUT sum int, OUT prod int) AS $$
BEGIN
     sum := x + y;
     prod := x * y;
END;
$$ LANGUAGE plpgsql;

And a table 'myvals' with x and y integer values:
CREATE TABLE myvals (INT x, INT y);


How can I do the following:

select * from myvals, sum_n_product(myvals.x, myvals.y);

Here I get an error:
ERROR:  function expression in FROM may not refer to other relations of
same query level

What I want is a view with the values:

x | y | sum | prod |


Best regards,

Heiko

В списке pgsql-general по дате отправления:

Предыдущее
От: Rich Shepard
Дата:
Сообщение: Re: Temporal Units
Следующее
От: "John D. Burger"
Дата:
Сообщение: Re: Temporal Units