<div class="gmail_quote"><div>Thank you Bogdan, actually this does a proper job. What I was doing was slightly different which I realized later, I was trying to initialize the AVP like this directly in my script:</div><div>
$avp(i:999) = 0;</div><div>$(avp(variable)[$avp(i:999]) = $avp(value);</div><div><br></div><div>This results an error in syslog saying: </div><div>ERROR:core:pv_set_avp: Failed to replace avp</div><div>ERROR:core:do_assign: setting PV failed</div>
<div><br></div><div>I guess initializing an AVP is important with some value before assigning a value to certain index, something like this:</div><div>$avp(variable) = $avp(default_value);</div><div><div>$avp(i:999) = 0;</div>
<div>$(avp(variable)[$avp(i:999]) = $avp(value);</div></div><div><br></div><div>This works properly !!! So is it good to conclude that initializing an AVP is important before trying to assign a value at any particular index.</div>
<div><br></div><div>--- Jayesh</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Jayesh,<br>
<br>
Just tried the following script and it did the right job:<br>
<br>
<snap><br>
$avp(s:value1) = "abc";<br>
$avp(s:value2) = "ABC";<br>
<br>
$avp(s:variable) = $avp(s:value1);<br>
$avp(i:999) = 0;<br>
$(avp(s:variable)[$avp(i:999)]) = $avp(s:value2);<br>
<br>
avp_print();<br>
</snap><br>
<br>
and the result (from avp_print()) :<br>
<br>
Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp: p=0xb5ab5e48,<br>
flags=0x0000<br>
Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp:<br>
id=<999><br>
Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp:<br>
val_int=<0><br>
Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp: p=0xb5ab5e70,<br>
flags=0x0003<br>
Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp:<br>
name=<variable><br>
Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp:<br>
val_str=<ABC / 3><br>
Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp: p=0xb5ab5dc8,<br>
flags=0x0003<br>
Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp:<br>
name=<value2><br>
Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp:<br>
val_str=<ABC / 3><br>
Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp: p=0xb5ab5d88,<br>
flags=0x0003<br>
Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp:<br>
name=<value1><br>
Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp:<br>
val_str=<abc / 3><br>
<br>
<br>
Can you post the error/log you get?<br>
<br>
Regards,<br>
Bogdan<br>
<br>
Jayesh Nambiar wrote:<br>
> Hi All,<br>
> I am trying to overwrite certain values at specific index of AVP and<br>
> it doesn't work as expected. How I do it is:<br>
><br>
> $avp(variable) = $avp(value1);<br>
> $avp(i:999) = 0;<br>
> $(avp(variable)[$avp(i:999)]) = $avp(value2);<br>
><br>
> While executing this, opensips logs an error saying unable to replace<br>
> AVPs. Is the syntax wrong somewhere? I do this as I don't want to add<br>
> multiple values into single AVP and also I dont want to call<br>
> avp_delete function before assigning a new value to the AVP. Moreover<br>
> the value at $avp(i:999) can change and thus it is assigned to another<br>
> AVP.<br>
><br>
> Any help related to AVP overwriting function would be very helpful.<br>
><br>
> --- Jayesh<br></blockquote></div>