
September 2nd, 2012, 08:58 AM
|
|
Registered User
|
|
Join Date: Sep 2012
Posts: 2
Time spent in forums: 13 m 51 sec
Reputation Power: 0
|
|
|
Using Function to reduce column value
Hi,
I am currently trying to use a function to reduce the value of a particular column in a view I have created.
The function is as follows:
create type holder as (name1 text, title1 text, count1 int);
create or replace function coauthorcount1() returns setof holder1 as
'
declare
r holder1%rowtype;
begin
for r in select name, title, count
from nametitlecount LOOP
r.count1 := r.count1 - 1;
end loop;
return;
end
'
language 'plpgsql';
The table consists of 3 columns: Name, Title and Count.
I am trying to decrement the count values by 1 but it doesn't seem to be working when I run the function using 'select 'coauthorcount();'.
I just get an output of '(0 rows)'.
Any help would be greatly appreciated.
Cheers
|