<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6001.18248" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV dir=ltr align=left><SPAN class=815403702-21072009><FONT face=Arial 
color=#0000ff size=2>What kind of operation?  Even an update statement 
might suffice.  There are many ways to cleverly control the flow of an 
update that do not necessitate doing a loop or cursor.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=815403702-21072009><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=815403702-21072009><FONT face=Arial 
color=#0000ff size=2>Also keep in mind even within a function used in 
a  SELECT statement of a query, PostgreSQL allows you to run updates 
and do all sorts of crazy things like launch perl scripts and bash 
scripts.  So for example you can mail to your whole membership simple by 
doing this</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=815403702-21072009><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=815403702-21072009><FONT face=Arial 
color=#0000ff size=2>SELECT member_name, send_mail(member_id) As 
did_it_send</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=815403702-21072009><FONT face=Arial 
color=#0000ff size=2>FROM membership</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=815403702-21072009><FONT face=Arial 
color=#0000ff size=2>WHERE gross_income > 1000000 and active = 
true</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=815403702-21072009><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=815403702-21072009><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=815403702-21072009><FONT face=Arial 
color=#0000ff size=2>It is very convenient for making rule 
processors.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=815403702-21072009><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=815403702-21072009><FONT face=Arial 
color=#0000ff size=2>Leo</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=815403702-21072009><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> 
postgis-users-bounces@postgis.refractions.net 
[mailto:postgis-users-bounces@postgis.refractions.net] <B>On Behalf Of </B>Bob 
Pawley<BR><B>Sent:</B> Monday, July 20, 2009 1:43 PM<BR><B>To:</B> PostGIS Users 
Discussion<BR><B>Subject:</B> [postgis-users] Loop or 
Cursor<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><FONT face=Arial size=2>Hi</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I need to access a number of rows, one at a time to 
perform an operation on each.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Under what conditions would I consider using a loop 
command, rather than (or with) a cursor?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Bob</FONT></DIV></BODY></HTML>