Re: Function return number of affected rows

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Francisco Figueiredo Jr(dot)" <fxjrlists(at)yahoo(dot)com(dot)br>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Function return number of affected rows
Date: 2005-02-12 19:08:00
Message-ID: 22824.1108235280@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

"Francisco Figueiredo Jr." <fxjrlists(at)yahoo(dot)com(dot)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

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message b t 2005-02-13 03:39:17 How to use UDF in C
Previous Message Francisco Figueiredo Jr. 2005-02-12 18:42:24 Re: Function return number of affected rows