<div dir="ltr">Thanks David.<div><br></div><div>Looking though the code, I see that the LIMIT 1 clause is used several times in contexts similar to this:</div><div><br></div><div><br></div><div><div> /* Checking for cid field, adding if needed */</div><div> if (db_check("SELECT cid FROM lcr LIMIT 1") == SWITCH_TRUE) {</div><div> switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "cid field defined.\n");</div></div><div><br></div><div>I gather they are limiting to 1 record because there might be people that have huge tables and it wouldn't make sense to bring back all those records...</div><div><br></div><div>But as can be seen below, limiting records doesn't seem to be one of those standard SQL things...</div><div><br></div><div><br></div><div><p style="box-sizing:border-box;margin:0px 0px 11px;color:rgb(51,51,51);font-family:georgia,"times new roman",times,serif;font-size:16px">Returning only the first N records in a SQL query differs quite a bit between database platforms. Here's some samples:</p><p style="box-sizing:border-box;margin:0px 0px 11px;color:rgb(51,51,51);font-family:georgia,"times new roman",times,serif;font-size:16px"><strong style="box-sizing:border-box">Microsoft SQL Server</strong></p><pre class="gmail-pre-scrollable" style="box-sizing:border-box;overflow-x:auto;overflow-y:scroll;font-family:menlo,monaco,consolas,"courier new",monospace;font-size:9pt;padding:5px;margin-top:0px;margin-bottom:11px;line-height:1.42857;word-break:break-all;word-wrap:normal;color:rgb(51,51,51);background-color:rgb(251,251,251);border-width:1px 1px 1px 2px;border-style:solid;border-color:rgb(204,204,204) rgb(204,204,204) rgb(204,204,204) silver;border-radius:4px;width:1038.33px;max-height:340px">SELECT <strong style="box-sizing:border-box">TOP 10</strong> column FROM table
</pre><p style="box-sizing:border-box;margin:0px 0px 11px;color:rgb(51,51,51);font-family:georgia,"times new roman",times,serif;font-size:16px"><strong style="box-sizing:border-box">PostgreSQL and MySQL</strong></p><pre class="gmail-pre-scrollable" style="box-sizing:border-box;overflow-x:auto;overflow-y:scroll;font-family:menlo,monaco,consolas,"courier new",monospace;font-size:9pt;padding:5px;margin-top:0px;margin-bottom:11px;line-height:1.42857;word-break:break-all;word-wrap:normal;color:rgb(51,51,51);background-color:rgb(251,251,251);border-width:1px 1px 1px 2px;border-style:solid;border-color:rgb(204,204,204) rgb(204,204,204) rgb(204,204,204) silver;border-radius:4px;width:1038.33px;max-height:340px">SELECT column FROM table
<strong style="box-sizing:border-box">LIMIT 10</strong>
</pre><p style="box-sizing:border-box;margin:0px 0px 11px;color:rgb(51,51,51);font-family:georgia,"times new roman",times,serif;font-size:16px"><strong style="box-sizing:border-box">Oracle</strong></p><pre class="gmail-pre-scrollable" style="box-sizing:border-box;overflow-x:auto;overflow-y:scroll;font-family:menlo,monaco,consolas,"courier new",monospace;font-size:9pt;padding:5px;margin-top:0px;margin-bottom:11px;line-height:1.42857;word-break:break-all;word-wrap:normal;color:rgb(51,51,51);background-color:rgb(251,251,251);border-width:1px 1px 1px 2px;border-style:solid;border-color:rgb(204,204,204) rgb(204,204,204) rgb(204,204,204) silver;border-radius:4px;width:1038.33px;max-height:340px">SELECT column FROM table
<strong style="box-sizing:border-box">WHERE ROWNUM <= 10</strong>
</pre><p style="box-sizing:border-box;margin:0px 0px 11px;color:rgb(51,51,51);font-family:georgia,"times new roman",times,serif;font-size:16px"><strong style="box-sizing:border-box">Sybase</strong></p><pre class="gmail-pre-scrollable" style="box-sizing:border-box;overflow-x:auto;overflow-y:scroll;font-family:menlo,monaco,consolas,"courier new",monospace;font-size:9pt;padding:5px;margin-top:0px;margin-bottom:11px;line-height:1.42857;word-break:break-all;word-wrap:normal;color:rgb(51,51,51);background-color:rgb(251,251,251);border-width:1px 1px 1px 2px;border-style:solid;border-color:rgb(204,204,204) rgb(204,204,204) rgb(204,204,204) silver;border-radius:4px;width:1038.33px;max-height:340px"><strong style="box-sizing:border-box">SET rowcount 10</strong>
SELECT column FROM table
</pre><p style="box-sizing:border-box;margin:0px 0px 11px;color:rgb(51,51,51);font-family:georgia,"times new roman",times,serif;font-size:16px"><strong style="box-sizing:border-box">Firebird</strong></p><pre class="gmail-pre-scrollable" style="box-sizing:border-box;overflow-x:auto;overflow-y:scroll;font-family:menlo,monaco,consolas,"courier new",monospace;font-size:9pt;padding:5px;margin-top:0px;margin-bottom:11px;line-height:1.42857;word-break:break-all;word-wrap:normal;color:rgb(51,51,51);background-color:rgb(251,251,251);border-width:1px 1px 1px 2px;border-style:solid;border-color:rgb(204,204,204) rgb(204,204,204) rgb(204,204,204) silver;border-radius:4px;width:1038.33px;max-height:340px">SELECT <strong style="box-sizing:border-box">FIRST 10</strong> column
FROM table</pre></div><div><br></div><div><br></div><div>I'm wondering if they couldn't do something like "select distinct XXXX.." to mitigate this, but still be compatible with all ODBC backends. SELECT DISTINCT seems to be standard (at least I checked ORACLE, POSTGRES, mySQL and MSSQL.</div><div><br></div><div>Guillermo</div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 7, 2016 at 8:29 PM, David Villasmil <span dir="ltr"><<a href="mailto:david.villasmil.work@gmail.com" target="_blank">david.villasmil.work@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">It shouldn't be too hard to patch it for MSSQL, maybe that's the way to go.<div>I have no idea whether anyone's implemented that, sorry.</div></div><div hspace="streak-pt-mark" style="max-height:1px"><img style="width:0px;max-height:0px;overflow:hidden" src="https://mailfoogae.appspot.com/t?sender=aZGF2aWQudmlsbGFzbWlsLndvcmtAZ21haWwuY29t&type=zerocontent&guid=88edaf59-b62e-4dcd-8d26-36ee767f4f7f"><font color="#ffffff" size="1">ᐧ</font></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 8, 2016 at 1:26 AM, Guillermo Ruiz Camauer <span dir="ltr"><<a href="mailto:grcamauer@gmail.com" target="_blank">grcamauer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Yes, I have ODBC working on my FS box, and I have updated the lcr.conf.xml file with the DSN.<div>The problem is that when I load the module I get errors like:</div><div><br></div><div><div>2016-10-06 15:35:35.560192 [ERR] switch_odbc.c:522 ERR: [SELECT codec FROM carrier_gateway LIMIT 1]</div><div>[STATE: 42000 CODE 102 ERROR: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Incorrect syntax near '1'.</div><div>]</div><div>2016-10-06 15:35:35.560212 [ERR] switch_core_sqldb.c:587 ODBC SQL ERR [STATE: 42000 CODE 102 ERROR: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Incorrect syntax near '1'.</div><div>]</div><div>SELECT codec FROM carrier_gateway LIMIT 1</div></div><div><br></div><div>MSSQL doesn't accept "LIMIT 1". The equivalent syntax would be "SELECT top 1 codec FROM carrier_gateway".</div><div><br></div><div>I was wondering if I will have to make a custum version of mod_lcr (which I must then maintain), or if there is some setting that I am not seeing to make it compatible with MS SQL.</div><div>If anybody has gone down this road, would like some feedback.</div><div><br></div><div>Thanks!</div></div><div class="gmail_extra"><div><div class="m_-7406608409193382414h5"><br><div class="gmail_quote">On Fri, Oct 7, 2016 at 8:12 PM, David Villasmil <span dir="ltr"><<a href="mailto:david.villasmil.work@gmail.com" target="_blank">david.villasmil.work@gmail.co<wbr>m</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">You can probably just use odbc, have you tried that?</div><div hspace="streak-pt-mark" style="max-height:1px"><img style="width:0px;max-height:0px;overflow:hidden" src="https://mailfoogae.appspot.com/t?sender=aZGF2aWQudmlsbGFzbWlsLndvcmtAZ21haWwuY29t&type=zerocontent&guid=f68fce25-d14f-4d87-94e0-e23779020f4b"><font color="#ffffff" size="1">ᐧ</font></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_-7406608409193382414m_2254711236529165387h5">On Sat, Oct 8, 2016 at 1:10 AM, Guillermo Ruiz Camauer <span dir="ltr"><<a href="mailto:grcamauer@gmail.com" target="_blank">grcamauer@gmail.com</a>></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 class="m_-7406608409193382414m_2254711236529165387h5"><div dir="ltr">Does anyone have mod_lcr running against a MSSQL database through ODBC? What modifications did you have to make?<span class="m_-7406608409193382414m_2254711236529165387m_-6508860443951375755HOEnZb"><font color="#888888"><br clear="all"><div><br></div>-- <br><div class="m_-7406608409193382414m_2254711236529165387m_-6508860443951375755m_-5722558001572916920gmail_signature" data-smartmail="gmail_signature">Guillermo Ruiz Camauer<br></div>
</font></span></div>
<br></div></div>______________________________<wbr>______________________________<wbr>_____________<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" rel="noreferrer" target="_blank">http://www.freeswitchsolutions<wbr>.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" rel="noreferrer" target="_blank">http://confluence.freeswitch.o<wbr>rg</a><br>
<a href="http://www.cluecon.com" rel="noreferrer" 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.freeswi<wbr>tch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/ma<wbr>ilman/listinfo/freeswitch-user<wbr>s</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.frees<wbr>witch.org/mailman/options/free<wbr>switch-users</a><br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br></blockquote></div><br></div>
<br>______________________________<wbr>______________________________<wbr>_____________<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" rel="noreferrer" target="_blank">http://www.freeswitchsolutions<wbr>.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" rel="noreferrer" target="_blank">http://confluence.freeswitch.o<wbr>rg</a><br>
<a href="http://www.cluecon.com" rel="noreferrer" 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.freeswi<wbr>tch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/ma<wbr>ilman/listinfo/freeswitch-user<wbr>s</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.frees<wbr>witch.org/mailman/options/free<wbr>switch-users</a><br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="m_-7406608409193382414HOEnZb"><font color="#888888">-- <br><div class="m_-7406608409193382414m_2254711236529165387gmail_signature" data-smartmail="gmail_signature">Guillermo Ruiz Camauer<br></div>
</font></span></div>
<br>______________________________<wbr>______________________________<wbr>_____________<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" rel="noreferrer" target="_blank">http://www.freeswitchsolutions<wbr>.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" rel="noreferrer" target="_blank">http://confluence.freeswitch.o<wbr>rg</a><br>
<a href="http://www.cluecon.com" rel="noreferrer" 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.freeswi<wbr>tch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/ma<wbr>ilman/listinfo/freeswitch-user<wbr>s</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.frees<wbr>witch.org/mailman/options/<wbr>freeswitch-users</a><br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br></blockquote></div><br></div>
</div></div><br>______________________________<wbr>______________________________<wbr>_____________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" rel="noreferrer" target="_blank">http://www.<wbr>freeswitchsolutions.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" rel="noreferrer" target="_blank">http://confluence.freeswitch.<wbr>org</a><br>
<a href="http://www.cluecon.com" rel="noreferrer" 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.<wbr>freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/<wbr>mailman/listinfo/freeswitch-<wbr>users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.<wbr>freeswitch.org/mailman/<wbr>options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Guillermo Ruiz Camauer<br></div>
</div>