From: | Misa Simic <misa(dot)simic(at)gmail(dot)com> |
---|---|
To: | Kevin Duffy <kevind0718(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: function return update count |
Date: | 2012-01-06 07:34:23 |
Message-ID: | 7168163483604200082@unknownmsgid |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
You could try:
1) return UPDATE table
OR
2) use plpsql function instead of SQL
UPDATE table
GET DIAGNOSTICS <variable> = ROW_COUNT
RETURN <variable>
Kind regards,
Misa
Sent from my Windows Phone
------------------------------
From: Kevin Duffy
Sent: 06/01/2012 06:21
To: pgsql-general(at)postgresql(dot)org
Subject: [GENERAL] function return update count
Hello:
I am try to get a function to return the count of the rows updated within
the function.
As in the following, I wan the number of rows updated to be returned.
This is a simple update, other update statements that I need to write will
be complicated.
CREATE OR REPLACE FUNCTION est_idio_return_stats_update()
RETURNS integer AS
'
update est_idiosyncratic_return_stats set delta_avg_60 = avg_60 -
period_61_return, delta_avg_last_24 = avg_last_24 - period_61_return,
delta_avg_last_18 = avg_last_18 - period_61_return,
delta_avg_last_12 = avg_last_12 - period_61_return,
delta_avg_last_6 = avg_last_06 - period_61_return ;
'
LANGUAGE SQL ;
The above returns the following:
ERROR: return type mismatch in function declared to return integer
DETAIL: Function's final statement must be SELECT or INSERT/UPDATE/DELETE
RETURNING.
CONTEXT: SQL function "est_idio_return_stats_update"
********** Error **********
ERROR: return type mismatch in function declared to return integer
SQL state: 42P13
Detail: Function's final statement must be SELECT or INSERT/UPDATE/DELETE
RETURNING.
Context: SQL function "est_idio_return_stats_update"
Thanks for your kind assistance.
KD
From | Date | Subject | |
---|---|---|---|
Next Message | Misa Simic | 2012-01-06 07:37:25 | Re: function return update count |
Previous Message | Andreas Kretschmer | 2012-01-06 07:29:32 | Re: function return update count |