[postgis-users] plpgsql function

alex bodnaru alexbodn at 012.net.il
Sat Feb 21 01:37:00 PST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


hi

eehab hamzeh wrote:
> 
> 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
> 
you could check if table empty in another function, and invoke it inside that loop.
>  
> 
> 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;
btw: your syntax is questionable here ;)
> 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! Try it!
> <http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

- --
- --
best regards,
alex
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iJwEAQECAAYFAkmfyzwACgkQ2nA3WyrfyeNfVwQAoRC/6cfEFZv1TxJwtUBfTzyP
SWeBhh846OU86VRFjIPU3k04BMvPYUsl0txjOGAZHISS+NfR058C64AR81dCZei9
51wTMGnVDo7sfqyYKdJYwTEvHxJ0fecDk+p2f7tS8SBqGMrDohtRz2uB0xHBpY5j
m8rk502rpR7K9ZIWLFA=
=LXNU
-----END PGP SIGNATURE-----



More information about the postgis-users mailing list