- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
create or replace function t8() returns integer as $$
declare
rec record;
begin
for rec in select * from purchase loop
update purchase set amount=(
select book.cost*purchase.quantity*(1-customer.discount/100.0)
from purchase, book, customer
where purchase.id=rec.id and
book.id=purchase.book and
customer.id=purchase.customer
)
where purchase.id=rec.id;
end loop;
return 1;
end;
$$ language plpgsql;
select t8();
Lure Of Chaos 04.04.2011 21:05 # +1
eth0 05.04.2011 18:12 # 0