[postgis-users] plpgsql function
eehab hamzeh
eehab40 at hotmail.com
Sat Feb 21 01:20:11 PST 2009
hello and thanks for your usefull replay
the following function goes through foo table rows and fetch it to a variable rowtype using cursor
i need to use the variable of one of the column to be pased to another function... if result is null i need to do insert and delete on tables if result is not null i need the function to continue loop through the rest of rows. untill the rows are finished.
the function tw if it is not null it adds value to the table foo... how i can make the loop updated automaticlly so the function c5c will continue run untill the table foo is emptey
Kind regards
ihab
CREATE OR REPLACE FUNCTION c5c()RETURNS boolean AS'
declare
mycursor cursor for select *from foo;
pre foo%rowtype;
begin
open mycursor;
loop
fetch mycursor into pre;
exit when not found;
if select from tw(pre.fooid) is null then
insert into end(id) select id from foo where id=pre.fooid;
delete from foo(id) select id from foo where id=pre.fooid;
end if;
end loop;
close mycursor;
return true;
end;
' LANGUAGE 'plpgsql'
_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20090221/8c0b8809/attachment.html>
More information about the postgis-users
mailing list