Guys thank you very much for all your answers. It is a very educational process writing and reading from the users list.
For new people in kamailio like myself , the users list is the best way to learn AFTER reading the official documentation.

Thank you once again

P.S. For the records I'm attaching the script i wrote to implement the portability
Cheers
Alex

The scenario is that we expect calls from customers which we route through a special prefix that they are sending us. For some customers we terminate ported numbers and for others not.That depends on the contract they have.
Anyway the script which i will test heavily tomorrow:

From the prefix to domain translation i  expect back a value string with 4 numbers separated from dot's .
10.1.1.5
number called 1001 210XXXXXXX   1001=cust prefix and 210XXXXXX number

$var(dial_grp) = 10 the dialplan group in the dialplan query next one.values .0-100
$var(check_p) = 1 if we want to check number for portability . values 0-1
$var(term_p) = 1 if the number is ported if we want to terminate it anyway.  values  0-1
$var(num_pr) = 4  this is the prefix(number of digits we want to remove before the checking of portability)
if(prefix2domain("2", "0")) {

                $var(dial_grp)  = $(rd{s.select,0,.}{s.int});
                $var(check_p) = $(rd{s.select,1,.}{s.int});
                $var(term_p)   = $(rd{s.select,2,.}{s.int});
                $var(num_pr)  = $(rd{s.select,3,.}{s.int});

                $rU = $(rU{s.substr,$var(num_pr),0}); # we cat the prefix here

 if($var(check_p)==1){

       sql_query("ca", "SELECT prefix FROM ported WHERE phonenumber='$rU'", "ra");
       $rU = '' + $dbr(ra=>[0,0]) + $rU;

       if($var(term_p)==0){
                                  xlog("alx ------- We dont terminate this ported number!!!! ----------");
                                  sl_send_reply("503","Congestion");
                                  exit;

                                }
        sql_result_free("ra");

   }

 




On Mon, Dec 21, 2009 at 10:51 PM, Alex Balashov <abalashov@evaristesys.com> wrote:
On 12/21/2009 03:50 PM, Henning Westerholt wrote:
On Mon, December 21, 2009 5:37 pm, Alex Balashov wrote:
Try:  if(is_avp_set("$avp(s:lnp_prefix)"))

Hey Alex,

also possible is to use it: if (! $avp(s:lnp_prefix)) which is shorter and
don't rely on the avpops module to test for null. (In sr the "defined"
operator can be used for the same purpose.

I thought that would evaluate the numerical expression value of the AVP, not whether it is null?


--
Alex Balashov - Principal
Evariste Systems
Web     : http://www.evaristesys.com/
Tel     : (+1) (678) 954-0670
Direct  : (+1) (678) 954-0671