FUNCTION problem

Поиск
Список
Период
Сортировка
От Peter Willis
Тема FUNCTION problem
Дата
Msg-id 49D3F948.4060908@borstad.com
обсуждение исходный текст
Ответы Re: FUNCTION problem  (Adrian Klaver <aklaver@comcast.net>)
Список pgsql-sql
Hello,

I am having a problem with a FUNCTION.
The function creates just fine with no errors.

However, when I call the function postgres produces an error.

Perhaps someone can enlighten me.


--I can reproduce the error by making a test function
--that is much easier to follow that the original:

CREATE OR REPLACE FUNCTION test_function(integer)  RETURNS SETOF RECORD AS
$BODY$  DECLARE croid integer;  BEGIN
--PERFORM A SMALL CALCULATION--DOESNT SEEM TO MATTER WHAT IT IS
SELECT INTO croid 2;--A SELECT STATEMENT OUTPUTS RECORDS (one in this case)SELECT croid,$1;  END;

$BODY$  LANGUAGE 'plpgsql' VOLATILE




--The call looks like the following:

SELECT test_function(1);





--The resulting error reads as follows:

ERROR:  query has no destination for result data
HINT:  If you want to discard the results of a SELECT, use PERFORM instead.
CONTEXT:  PL/pgSQL function "test_function" line 5 at SQL statement

********** Error **********

ERROR: query has no destination for result data
SQL state: 42601
Hint: If you want to discard the results of a SELECT, use PERFORM instead.
Context: PL/pgSQL function "test_function" line 5 at SQL statement


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

Предыдущее
От: "Deirdre Hall"
Дата:
Сообщение: Re: Stored function not accepting null value?
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: FUNCTION problem