Re: Function return number of affected rows

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Function return number of affected rows
Дата
Msg-id 22824.1108235280@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Function return number of affected rows  ("Francisco Figueiredo Jr." <fxjrlists@yahoo.com.br>)
Ответы Re: Function return number of affected rows  ("Francisco Figueiredo Jr." <fxjrlists@yahoo.com.br>)
Список pgsql-interfaces
"Francisco Figueiredo Jr." <fxjrlists@yahoo.com.br> writes:
> But if I create a function like:

> create function inserttest() returns void as ' insert into table1
> values(1, 1)' language 'sql';

> and I do a select * from inserttest();

> I can't get the CompletedResponse saying one row was affected :(

Why should you?  What you executed was a SELECT.  What the function does
internally is no business of yours.

You could define the function as returning the information you would
like to have the client app know.  I don't think there is any way to get
at the rowcount in a SQL-language function, but most of the PL languages
have a mechanism for it, e.g. GET DIAGNOSTICS integer_var = ROW_COUNT;
in plpgsql.
        regards, tom lane


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

Предыдущее
От: "Francisco Figueiredo Jr."
Дата:
Сообщение: Re: Function return number of affected rows
Следующее
От: b t
Дата:
Сообщение: How to use UDF in C