Re: Function return number of affected rows - Mailing list pgsql-interfaces

From Michael Fuhr
Subject Re: Function return number of affected rows
Date
Msg-id 20050210221505.GA73565@winnie.fuhr.org
Whole thread Raw
In response to Re: Function return number of affected rows  ("Francisco Figueiredo Jr." <fxjrlists@yahoo.com.br>)
Responses Re: Function return number of affected rows  ("Francisco Figueiredo Jr." <fxjrlists@yahoo.com.br>)
List 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 by date:

Previous
From: Tom Lane
Date:
Subject: Re: Help with adding C-Language Functions
Next
From: Seamus Thomas Carroll
Date:
Subject: Re: Help with adding C-Language Functions