Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Icon > Re: Generator "...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 6 Topic 132 of 189
Post > Topic >>

Re: Generator "Cleanup" Question

by gmt@[EMAIL PROTECTED] (Gregg Townsend) Nov 27, 2006 at 07:40 PM

> procedure dbi_conn_find(dbi_conn, sql)
>	local res, row
>	res := dbi_conn_query(dbi_conn, sql)
>	every row := dbi_result_fetch_next_table(res) do {
>		suspend row
>	}
>	dbi_result_free(res)
> end
>
> The result *must* be freed. So, with the above procedure, the following
> works just fine:
>
> every row := dbi_conn_find(conn, "SELECT * FROM people WHERE name =
> 'JOHN'") do
>    write_person(row)
>
> However:
>
> first := dbi_conn_find(conn, "SELECT * FROM people WHERE name =
> 'JOHN'")
>
> will fail to call "dbi_result_free".
>
> Any thoughts on how to handle this?

When a generator suspends, it can't assume it will ever be resumed.
For the example you gave, I'd probably read fetch all the results
into an array, close the database connection, and then generate the
array contents.  Of course, that assumes that the results can fit
in memory reasonably.

---------------------------------------------------------------------------
Gregg Townsend         Staff Scientist      The University of Arizona
gmt@[EMAIL PROTECTED]
     Computer Science     Tucson, Arizona, USA
 




 6 Posts in Topic:
Generator "Cleanup" Question
Cp200205@[EMAIL PROTECTED  2006-11-26 08:22:20 
Re: Generator "Cleanup" Question
gmt@[EMAIL PROTECTED] (G  2006-11-27 19:40:23 
Re: Generator "Cleanup" Question
espie@[EMAIL PROTECTED]   2006-11-27 20:45:30 
Re: Generator "Cleanup" Question
Steve Wampler <swample  2006-11-27 14:12:14 
Re: Generator "Cleanup" Question
Cp200205@[EMAIL PROTECTED  2006-11-27 14:15:29 
Re: Generator "Cleanup" Question
Steve Wampler <swample  2006-11-27 16:22:42 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 22:40:53 CDT 2008.