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

From Tom Lane
Subject Re: Function return number of affected rows
Date
Msg-id 22824.1108235280@sss.pgh.pa.us
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
List 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 by date:

Previous
From: "Francisco Figueiredo Jr."
Date:
Subject: Re: Function return number of affected rows
Next
From: b t
Date:
Subject: How to use UDF in C