Write a cursor to display the names of suppliers in ‘Pune’ city.
Write a cursor to display the names of suppliers in ‘Pune’ city.
==>
CREATE OR REPLACE FUNCTION item () returns void as
'
declare
c1 cursor for select * from supplier ;
r1 supplier%rowtype;
begin
open c1;
loop
fetch c1 into r1;
exit when not found;
if r1.city = ''pune'' then
raise notice '' %'',r1.city;
end if;
end loop;
close c1;
end;
'language'plpgsql';
Output of function
Acode2=# select item();
o\p
Acode2=# select item();
item
------
(1 row)
0 Comments