Re: Function return number of affected rows

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Function return number of affected rows
Дата
Msg-id 20050210221505.GA73565@winnie.fuhr.org
обсуждение исходный текст
Ответ на 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
On Thu, Feb 10, 2005 at 02:51:46PM -0200, Francisco Figueiredo Jr. wrote:
> Michael Fuhr wrote:
> >Does Npgsql use its own implemention of the PostgreSQL protocol?
> >If so, then that implementation will have to provide the desired
> >functionality itself.
> 
> Yeap. Npgsql implements protocol itself. This is exactly the problem. 
> I'm not receiving the CompletedResponse protocol message when executing 
> the insert inside a function. It is through the CompletedResponse 
> postgresql server says how many rows were affected. But it seems that 
> when calling a function it doesn't return any.

I haven't used Npgsql, but the documentation has an example with
the following code:
 NpgsqlCommand command = new NpgsqlCommand("insert into table1 values(1, 1)", conn); Int32 rowsaffected;    try {
rowsaffected= command.ExecuteNonQuery(); }
 

Is that what you're trying to do?  Does it not work?

I downloaded the latest Npgsql source and found the following in
ExecuteNonQuery():
 // The number of rows affected is in the third token for insert queries // and in the second token for update and
deletequeries. // In other words, it is the last token in the 0-based array.
 
 return Int32.Parse(ret_string_tokens[ret_string_tokens.Length - 1]);

It looks like ExecuteNonQuery() is at least attempting to return
the number of rows affected.

Have I misunderstood what you're doing?

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Help with adding C-Language Functions
Следующее
От: Seamus Thomas Carroll
Дата:
Сообщение: Re: Help with adding C-Language Functions