[postgis-users] Trigger question

Stephen Davies sdc at sdc.com.au
Tue Mar 27 22:55:15 PDT 2007


G'day all.
This is probably an FAQ but I don't see it.

I am trying to write a plpgsql trigger to calculate and store the area 
of a polygon but am getting no result.

The latest version of my code is:

create function setarea() returns trigger as $setarea$
declare
 a numeric (10,2);
begin
 select into a area(transform(NEW.geom,28354));
 NEW.area := a;
 return NEW;
end;
$setarea$ language plpgsql;
create trigger setarea after insert or update on unit for each row 
execute procedure setarea();

This generates no error at creation or update time but does not give me 
an area either.

What amI missing?

Cheers and thanks,
Stephen Davies
-- 
========================================================================
This email is for the person(s) identified above, and is confidential to
the sender and the person(s).  No one else is authorised to use or
disseminate this email or its contents.

Stephen Davies Consulting                            Voice: 08-8177 1595
Adelaide, South Australia.                             Fax: 08-8177 0133
Computing & Network solutions.                       Mobile:0403 0405 83



More information about the postgis-users mailing list