Thread: cursor/ array in a function

cursor/ array in a function

From
jprem
Date:
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.