From: Michael Fuhr <mike@fuhr.org>
To: Francisco Figueiredo Jr. <fxjrlists@yahoo.com.br>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: Function return number of affected rows
Date: Thu, 10 Feb 2005 15:15:05 -0700
Message-ID: <20050210221505.GA73565@winnie.fuhr.org> (raw)
In-Reply-To: <420B9122.2090802@yahoo.com.br>
References: <420B46AC.9080002@yahoo.com.br>
<20050210144654.GB68483@winnie.fuhr.org>
<420B9122.2090802@yahoo.com.br>
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 delete queries.
// 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/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: mike@fuhr.org, fxjrlists@yahoo.com.br
Subject: Re: Function return number of affected rows
In-Reply-To: <20050210221505.GA73565@winnie.fuhr.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox