<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello,<br>
<br>
the name of the avp in the second parameter has to match the value
in the 'attribute' column, like:<br>
<br>
avp_db_load("01344665544/username", "$avp(inbound)/LineIDs");<br>
<br>
If you want to load all the records, you have to specify flags, not
avp names, in the second parameter.<br>
<br>
Cheers,<br>
Daniel<br>
<br>
<div class="moz-cite-prefix">On 11/12/13 11:44 AM, Hugh James wrote:<br>
</div>
<blockquote
cite="mid:04764267EF93974CAAA93283D738DBD37D0D6E@EX01.semafone.local"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<style>
<!--
@font-face
{font-family:Calibri}
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif"}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif"}
span.EmailStyle17
{font-family:"Calibri","sans-serif";
color:windowtext}
.MsoChpDefault
{font-family:"Calibri","sans-serif"}
@page WordSection1
{margin:72.0pt 72.0pt 72.0pt 72.0pt}
div.WordSection1
{}
ol
{margin-bottom:0cm}
ul
{margin-bottom:0cm}
-->
</style>
<div class="WordSection1">
<p class="MsoNormal">Hi ,</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">I’m trying to use the db_text and avpops
modules to implement a simple custom database but having
problems getting it to work .</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">I’m trying to find the Identity of the
recipient for an inbound call based on the called number . I
have a database file:-</p>
<p class="MsoNormal"> </p>
<p class="MsoListParagraph" style="text-indent:-18.0pt"><span
style="">1)<span style="font:7.0pt "Times New
Roman"">
</span></span>LineIDs - contains the called numbers in the
username field and an attribute for that line ID (inbound/
outbound) ,and the recipient identity in the value field</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">I am trying to get the attribute and value
pairs that matches the line number in the user name column ,</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">id(int,auto) uuid(str,null) username(str)
domain(str,null) attribute(str) type(int) value(str)</p>
<p class="MsoNormal">1::+12125551212::inbound:0:Foster</p>
<p class="MsoNormal">2::012125551212::inbound:0:Foster</p>
<p class="MsoNormal">3::12125551212::inbound:0:Foster</p>
<p class="MsoNormal">4::+4412125551212::inbound:0:Foster</p>
<p class="MsoNormal">5::+12125551213::inbound:0:Foster</p>
<p class="MsoNormal">6::012125551213::inbound:0:Foster</p>
<p class="MsoNormal">7::013440001::inbound:0:Foster</p>
<p class="MsoNormal">8::call-centre::inbound:0:MBA</p>
<p class="MsoNormal">9::call-centre::outbound:0:MBA</p>
<p class="MsoNormal">10::01344665544::inbound:0:chicken</p>
<p class="MsoNormal">11::01344665544::outbound:0:chicken</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">I try to load the AVPs that match a
received number using the following line in the kamailio
script file
</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">
$var(rc)=avp_db_load("01344665544/username","s:recipient/LineIDs");</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">I have also tried </p>
<p class="MsoNormal" style="text-indent:36.0pt"> </p>
<p class="MsoNormal" style="text-indent:36.0pt">$var(rc)=avp_db_load("01344665544/username","$avp(s:tenants)/LineIDs");</p>
<p class="MsoNormal" style="text-indent:36.0pt"> </p>
<p class="MsoNormal">And </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal" style="text-indent:36.0pt">$var(rc)=avp_db_load("01344665544","$avp(i:123)/LineIDs");</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">But it fails to find any matching rows (
AVPS) . Am I using the function correctly ?</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">The debug output is shown below , there are
some custom debug lines I have added in the db_text C
files .</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">DEBUG: avpops [avpops_impl.c:378]: AVPOPS:
calls db_load_avp</p>
<p class="MsoNormal">DEBUG: db_text [dbt_base.c:185]: DBTEXT:
dbt_query called</p>
<p class="MsoNormal">DEBUG: db_text [dbt_file.c:102]: request
for table [LineIDs]</p>
<p class="MsoNormal">DEBUG: db_text [dbt_file.c:109]: db is
[/etc/kamailio/Tenants]</p>
<p class="MsoNormal">DEBUG: db_text [dbt_file.c:124]: loading
file [/etc/kamailio/Tenants/LineIDs]</p>
<p class="MsoNormal">DEBUG: db_text [dbt_tb.c:187]: mtime is
1383910898</p>
<p class="MsoNormal">DEBUG: db_text [dbt_file.c:215]: column[0]
is INT!</p>
<p class="MsoNormal">DEBUG: db_text [dbt_file.c:210]: column[1]
is STR!</p>
<p class="MsoNormal">DEBUG: db_text [dbt_file.c:210]: column[2]
is STR!</p>
<p class="MsoNormal">DEBUG: db_text [dbt_file.c:210]: column[3]
is STR!</p>
<p class="MsoNormal">DEBUG: db_text [dbt_file.c:210]: column[4]
is STR!</p>
<p class="MsoNormal">DEBUG: db_text [dbt_file.c:215]: column[5]
is INT!</p>
<p class="MsoNormal">DEBUG: db_text [dbt_file.c:210]: column[6]
is STR!</p>
<p class="MsoNormal">DEBUG: db_text [dbt_base.c:240]: new res
with 3 cols</p>
<p class="MsoNormal">DEBUG: db_text [dbt_res.c:52]: DBTEXT:
dbt_result_new called</p>
<p class="MsoNormal">DEBUG: db_text [dbt_res.c:79]: new res with
3 cols</p>
<p class="MsoNormal">DEBUG: db_text [dbt_res.c:100]: DBTEXT:
dbt_result_new returns</p>
<p class="MsoNormal">DEBUG: db_text [dbt_api.c:255]: DBTEXT:
dbt_get_result called</p>
<p class="MsoNormal">DEBUG: <core> [db_res.c:118]:
allocate 48 bytes for result set at 0x7f334a85c390</p>
<p class="MsoNormal">DEBUG: <core> [db_res.c:155]:
allocate 24 bytes for result names at 0x7f334a85c3e0</p>
<p class="MsoNormal">DEBUG: <core> [db_res.c:165]:
allocate 12 bytes for result types at 0x7f334a85c1f0</p>
<p class="MsoNormal">DEBUG: db_text [dbt_api.c:80]: allocate 16
bytes for RES_NAMES[0] at 0x7f334a85c1c0</p>
<p class="MsoNormal">DEBUG: db_text [dbt_api.c:80]: allocate 16
bytes for RES_NAMES[1] at 0x7f334a85c420</p>
<p class="MsoNormal">DEBUG: db_text [dbt_api.c:80]: allocate 16
bytes for RES_NAMES[2] at 0x7f334a85c450</p>
<p class="MsoNormal">DEBUG: db_text [dbt_api.c:281]: DBTEXT:
dbt_get_result returns 0</p>
<p class="MsoNormal">DEBUG: avpops [avpops_impl.c:389]: AVPOPS:
db_load_avp returns 0</p>
<p class="MsoNormal">DEBUG: avpops [avpops_db.c:271]: close avp
query</p>
<p class="MsoNormal">DEBUG: <core> [db_res.c:81]: freeing
3 columns</p>
<p class="MsoNormal">DEBUG: <core> [db_res.c:85]: freeing
RES_NAMES[0] at 0x7f334a85c1c0</p>
<p class="MsoNormal">DEBUG: <core> [db_res.c:85]: freeing
RES_NAMES[1] at 0x7f334a85c420</p>
<p class="MsoNormal">DEBUG: <core> [db_res.c:85]: freeing
RES_NAMES[2] at 0x7f334a85c450</p>
<p class="MsoNormal">DEBUG: <core> [db_res.c:94]: freeing
result names at 0x7f334a85c3e0</p>
<p class="MsoNormal">DEBUG: <core> [db_res.c:99]: freeing
result types at 0x7f334a85c1f0</p>
<p class="MsoNormal">DEBUG: <core> [db_res.c:136]: freeing
result set at 0x7f334a85c390</p>
<p class="MsoNormal">DEBUG: avpops [avpops_impl.c:420]: loaded
avps = 0</p>
<p class="MsoNormal">INFO: avp_db_load return result is -1</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">I was expecting it to return at least one
AVP .</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Any suggestions gratefully received .</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Hugh James</p>
<p class="MsoNormal"> </p>
</div>
<h1 style="font-family:Calibri,sans-serif; font-size:20px;
font-weight:bold; color:#4D4D4D">
Hugh James <span style="color:#808080">| Telephony Developer</span></h1>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td><img moz-do-not-send="true"
src="http://www.semafone.com/resources/signature/icons.jpg"
alt="icons"></td>
<td>
<ul style="font-family:Calibri,sans-serif; color:#4D4D4D;
list-style:none; margin:0; padding:0; font-size:15px;
line-height:28px">
<li>0845 543 0822 </li>
<li><br>
</li>
<li><a class="moz-txt-link-abbreviated" href="mailto:Hugh.James@semafone.com">Hugh.James@semafone.com</a> </li>
<li><a moz-do-not-send="true"
href="http://www.semafone.com" style="color:#4D4D4D">www.semafone.com</a>
</li>
<li><a moz-do-not-send="true"
href="http://twitter.com/semafone"
style="color:#4D4D4D">@semafone</a> </li>
<li>SEMAFONE, 3 The Billings, Walnut Tree Close,
Guildford, Surrey GU1 4UL </li>
</ul>
</td>
</tr>
</tbody>
</table>
<img moz-do-not-send="true"
src="http://www.semafone.com/resources/signature/logo.jpg"
alt="logo">
<p style="font-size:11px; font-family:Calibri,sans-serif;
color:#4D4D4D">This e-mail is intended only for the addressee
named above. As this e-mail may contain confidential or
privileged information if you are not the named addressee or the
person responsible for delivering the message to the named
addressee, please telephone us immediately. Please note that we
cannot guarantee that this message, or any attachment, is virus
free or has not been intercepted and amended. The views of the
author may not necessarily reflect those of the Company.</p>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a>
Kamailio Advanced Trainings - Berlin, Nov 25-28
- more details about Kamailio trainings at <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a> -
</pre>
</body>
</html>