How to execute cursor in PostgreSQL?

Поиск
Список
Период
Сортировка
От Vinaya Torne
Тема How to execute cursor in PostgreSQL?
Дата
Msg-id CAF3Q6eC_5hGMyXn8+JrUCiS+8CY37nGtK-c3Va01KRddWyZAzg@mail.gmail.com
обсуждение исходный текст
Ответы Re: How to execute cursor in PostgreSQL?  (David G Johnston <david.g.johnston@gmail.com>)
Список pgsql-admin
Hi Admin 

Below  is my program for cursor, but I am not getting how to execute the cursor on a database.

Please suggest on this 

emp=# CREATE or replace function cursor_demo() returns integer as $$
declare 
emp_rec employee%rowtype;
emp cursor for select * from employee;
comm numeric(6,2);
begin
loop
fetch emp into emp_rec;
if emp_rec.deptno = 5 then 
comm:=emp_rec.salary*0.2;
else if emp_rec.deptno=8 then
comm:= emp_rec.salary*0.5;
else if emp_rec.deptno = 10 then
comm:=emp_rec.salary*0.3;
end if;
end if;
end if;
raise notice 'emp_rec.ename||emp_rec.deptno||emp_rec.salary||comm.';
exit when not found;
end loop;
close emp; 
end;
$$ language'plpgsql';

Thanks&Regards,
Vinaya Torne
 +91-9403150377

В списке pgsql-admin по дате отправления:

Предыдущее
От: John Scalia
Дата:
Сообщение: Re: Security with V9.3.3 standby servers
Следующее
От: David G Johnston
Дата:
Сообщение: Re: How to execute cursor in PostgreSQL?