Re: Function return number of affected rows - Mailing list pgsql-interfaces
From | Francisco Figueiredo Jr. |
---|---|
Subject | Re: Function return number of affected rows |
Date | |
Msg-id | 420E4E10.6090104@yahoo.com.br Whole thread Raw |
In response to | Re: Function return number of affected rows (Michael Fuhr <mike@fuhr.org>) |
Responses |
Re: Function return number of affected rows
|
List | pgsql-interfaces |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Michael Fuhr wrote: Hi Michael! | | 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? | Yeap. This works perfectly. | 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? | I think I didn't make myself clear enough :) When I send the update directly, Postgresql sends me back the CompletedResponse and I can see how many rows were affected. 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 :( PS.: Michael, you can talk more protocol-specific way. I'm one of the authors of Npgsql and I do have a little bit of protocol background. I didn't talk directly about protocol and etc because I wanted to explain my problem first :) Also, I did a test with psql and I could check that it also doesn't say me how many rows were affected. Can this mean that what I want may not be possible? Thank you very much for your feedback Michael. - -- Regards, Francisco Figueiredo Jr. Membro Fundador do Projeto MonoBrasil - MonoBrasil Project Founder Member http://monobrasil.softwarelivre.org - ------------- "Science without religion is lame; religion without science is blind." ~ ~ Albert Einstein -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iQEVAwUBQg5OEP7iFmsNzeXfAQLrAAf/XBi3nKXcye0S+AA4+jlKjMvJ6Vz0AOr+ /wRbBo7qJo0Zh7kdLC+ClYTeLBmVUUwMwOjqucJ+RqbrXHKbK0bSzbeKIhtRduAG 6pK3k2GUPYPy33EbEcPF8cBeD5E07xSgUEIPbt4ncKVU8IWVIcoTRDUPhQpCY9dF 2WQ5ZbFpvk4nEgrLxQLU08WVahTnqiqs+9xpLHw88sxeIfaNTM7Eow4doV//s2I7 2lKerVIyQrQ0RECHzRGwHTX93wa9s3h+sfbFDy+ZzTT3st4KXknbqqOFTEuwSMRd 24shXMmWZ8WzWU8bKrPmKG5ZICpNhwMg3dfWSbkjRETCkXsZeUQenA== =KIXu -----END PGP SIGNATURE-----
pgsql-interfaces by date: