<div dir="ltr">Thanks for all the other input but the resolution was to ditch ODBC and use pgsql// dsn. With ODBC I get 3 decimal places, with pgsql dsb I get the required 4. I think its a bit faster too.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 23 March 2015 at 18:40, Abaci B <span dir="ltr">&lt;<a href="mailto:abaci64@gmail.com" target="_blank">abaci64@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I&#39;m doing something very similar, this is what I use:<div><div><span style="white-space:pre-wrap"><br></span></div><div>local rate = string.format(&quot;%.4f&quot;, currency][&quot;rate&quot;])</div></div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 23, 2015 at 8:45 AM, Ítalo Rossi <span dir="ltr">&lt;<a href="mailto:italorossib@gmail.com" target="_blank">italorossib@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Yep, it&#39;s available and defaults to 6 decimal places, but looks like it&#39;s not a Lua issue...</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Mon, Mar 23, 2015 at 9:05 AM, Bote Man <span dir="ltr">&lt;<a href="mailto:bote_radio@botecomm.com" target="_blank">bote_radio@botecomm.com</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div link="blue" vlink="purple" lang="EN-US"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">I’m not much of a programmer, but can’t you specify a format to %f to force it to return 4 decimal places?<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Or is that not available in Lua?<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Bote<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p><div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt"><div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in"><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> John Carpenter<br><b>Sent:</b> Monday, 23 March, 2015 06:59<br><b>Subject:</b> Re: [Freeswitch-users] Problem with LUA dbh:query in Freeswitch<u></u><u></u></span></p></div></div><div><div><p class="MsoNormal"><u></u> <u></u></p><div><div><p class="MsoNormal">Thats it, changed connection to a pgsql:// dsn and I get four decimal places, changed it back to ODBC and back to 3 decimal places. <u></u><u></u></p></div><p class="MsoNormal">Thanks very much, been driving me mad<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">On 23 March 2015 at 10:23, Steven Ayre &lt;<a href="mailto:steveayre@gmail.com" target="_blank">steveayre@gmail.com</a>&gt; wrote:<u></u><u></u></p><div><p class="MsoNormal">Have you tried a pgsql:// dsn? In case the ODBC driver is having some truncating effect.<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p><div><div><div><p class="MsoNormal">On 22 March 2015 at 02:06, John Carpenter &lt;<a href="mailto:carpenter.john@gmail.com" target="_blank">carpenter.john@gmail.com</a>&gt; wrote:<u></u><u></u></p></div></div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in"><div><div><div><div><p class="MsoNormal" style="margin-bottom:12.0pt">I am trying to use Lua to retrieve some currency conversion rates from a postgres database. It works but the numeric field value is only returning the first three decimal places although if I list the data in postgres it has four decimal places. I may be doing something daft as I am quite new to Lua, sample code is below. Any ideas appreciated<u></u><u></u></p></div><p class="MsoNormal">regards, John<u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal"><b><span style="font-family:&quot;Courier New&quot;;color:black;background:#f3f3f3">local</span></b><span style="font-family:&quot;Courier New&quot;;color:black;background:#f3f3f3"> dbh = freeswitch.Dbh(<b>&quot;odbc://fs_odbc:fs_user:password&quot;</b>) <br><b>if</b> dbh:connected() == <b>false</b> <b>then</b> <br> freeswitch.consoleLog(<b>&quot;notice&quot;</b>, <b>&quot;dp.lua cannot connect to database&quot;</b> .. dsn .. <b>&quot;\n&quot;</b>) <br> <b>return</b> <br><b>end</b> <br><b>assert</b>(dbh:connected()) <br><br>e_rate = <b>1.123456789</b> <br><b>-- just a test</b> to see decimal places<br>freeswitch.consoleLog(<b>&quot;info&quot;</b>,<b>string.format</b>(<b>&quot; e_rate = %f&quot;</b>, e_rate)) <br><br><b>local</b> <b>function</b> eur2usd() <br>   <b>local</b> sql = <b>&quot;select eur2usd from currency order by id desc limit 1&quot;</b> <br>   dbh:query(sql, <b>function</b>(row) <br>       e_rate = row.eur2usd <br>       <b>end</b>) <br><b>end</b> <br><br><b>local</b> <b>function</b> eur2gbp() <br>   <b>local</b> sql = <b>&quot;select eur2gbp from currency order by id desc limit 1&quot;</b> <br>   dbh:query(sql, <b>function</b>(row) <br>       e_rate = row.eur2gbp <br>       <b>end</b>) <br><b>end</b> <br><br>eur2usd() <br>freeswitch.consoleLog(<b>&quot;info&quot;</b>,<b>string.format</b>(<b>&quot; euro2usd = %f&quot;</b>, e_rate)) <br>eur2gbp() <br>freeswitch.consoleLog(<b>&quot;info&quot;</b>,<b>string.format</b>(<b>&quot; euro2gbp = %f&quot;</b>, e_rate))</span><u></u><u></u></p></div><p class="MsoNormal"><u></u> <u></u></p></div></div></div><p class="MsoNormal"><u></u> <u></u></p></div></div></blockquote></div></div></div><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div></div></div><br></div></div><span>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" target="_blank">http://confluence.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br></span></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr">Ítalo Rossi<br></div></div>
</font></span></div>
<br>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" target="_blank">http://confluence.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br></blockquote></div><br></div>
</div></div><br>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" target="_blank">http://confluence.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br></blockquote></div><br></div>