Hi Leon, Thanks for your help. I have changed it according to your comment but I am still getting the looping error. Would you please take a look see what else I did wrong? Also, sip_user is an integer field, so I can't really use ''. Is there anyway to get around that? <configuration name="xml_odbc.conf" description="XML ODBC Configuration"> <settings> <param name="binding" value="directory"/> <param name="odbc-dsn" value="class5_odbc:root:abcd"/> <param name="debug" value="true"/> <param name="keep-files-around" value="true"/> </settings> <templates> <template name="default"> <document type="freeswitch/xml"> <section name="directory"> <xml-odbc-do name="query" on-empty-result-break-to="not-found" value="SELECT enabled, sip_password FROM agent WHERE sip_user = ${user} and enabled='t'"/> <domain name="${domain}"> <user id="${user}"> <params> <xml-odbc-do name="query" value="SELECT sip_password FROM agent WHERE sip_user = ${user}"> <param name="password" value="${sip_password}"/> </xml-odbc-do> </params> </user> </domain> </section> </document> </template> <template> <document type="freeswitch/xml"> <section name="result"> <result status="not found"/> </section> </document> </template> </templates> </configuration>