cursor/ array in a function

From: jprem <jprem(at)srmsoft(dot)co(dot)in>
To: pgman <pgman(at)candle(dot)pha(dot)pa(dot)us>, postgresql <pgsql-general(at)postgresql(dot)org>
Subject: cursor/ array in a function
Date: 2000-07-17 05:56:01
Message-ID: 39729FF1.D020D93E@srmsoft.co.in
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

hello,
i have a function and a trigger as below.
-----------------------------------------------------------------------------------

create function testfunction() returns opaque
as
'declare
del_gid integer;
len integer;
j integer;
begin
select into empcount emp_id from emp where emp_id not in
(select emp_id
from dept);
if found then
j=0;
while j = empcount loop
delete from emp where emp_id = empcount;
end loop;
end if;
return null;
end;'
language 'plpgsql';

create trigger testtrigger after delete on X for each row
execute procedure testfunction();
----------------------------------------------------------------------------------

the tables X,emp and dept are related.when i delete a value from X , i
need to check for some values of empid in dept.if those values are not
found in dept then i have to delete those corresponding values from emp.

i heard from the discussion forum that plpgsql doesn't support cursors.
what i need is to store a set of values i na variable and fetch one by
one.
can i use array in a function or how to achieve this functionality in
PostgreSQL 6.5.3 ?

can anyone help me ? thanx in advance.

Browse pgsql-general by date

  From Date Subject
Next Message Eric Jain 2000-07-17 06:11:31 RE: COUNT DISTINCT
Previous Message Philip Warner 2000-07-17 03:42:19 Answers to questions on changes to PostgreSQL license