<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello Elijah,<div><br></div><div>You can pass a function as second argument to dbh:query, like so:</div><div><br></div><div>dbh = freeswitch.Dbh(odbc_dsn, odbc_user, odbc_pass)</div><div>dbh:query("select * from some_table", function(row) -- here it loops through all rows</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>for key, val in pairs(row) do -- here it loops through all columns</div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-tab-span" style="white-space:pre">                </span></span><span class="Apple-style-span" style="white-space: pre; ">stream:write(string.format("%25s : %s\n", key, val))</span></div><div><div><span class="Apple-tab-span" style="white-space:pre">        </span>end</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>stream:write("\n")</div><div>end))</div><div><font class="Apple-style-span" face="monospace"><span class="Apple-style-span" style="white-space: pre;"><font class="Apple-style-span" face="Helvetica"><span class="Apple-style-span" style="white-space: normal;"><br></span></font></span></font></div><div>This will run the anonymous function for each row, where each iteration of the function will be passed a row in the form of a table.</div><div><br></div><div>Each row (table) will have the following syntax:</div><div><br></div><div>{ ["column_name_1"] = "row_value_1", ["column_name_2" = "row_value_2" }</div><div><br></div><div>There's more info here:</div><div><br></div><div><a href="http://wiki.freeswitch.org/wiki/Mod_lua#freeswitch.Dbh">http://wiki.freeswitch.org/wiki/Mod_lua#freeswitch.Dbh</a></div><div><br></div><div>and here:</div><div><br></div><div><a href="http://wiki.freeswitch.org/wiki/Lua_freeswitch_dbh">http://wiki.freeswitch.org/wiki/Lua_freeswitch_dbh</a></div><div><br></div><div>kind regards,</div><div><br></div><div>Leon</div><div><br></div><div><br></div><div><br><div><div>On Nov 24, 2010, at 1:11 AM, elijah wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Could you demonstrate how to iterate through multiple returned rows in Lua from the function Dbh:query?<div><br> </div> _______________________________________________<br>FreeSWITCH-users mailing list<br><a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>http://lists.freeswitch.org/mailman/listinfo/freeswitch-users<br>UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users<br>http://www.freeswitch.org<br></blockquote></div><br></div></div></body></html>