Detect and display countryname on it's countrycode

Hello all!
have the following task: I need to detect the country using it’s code in callerid(num) and then display callerid in format callerid(num)-CountryName on the internal phone calls will be routed to.
I’m going to use internal AstDB to store countries and their codes using following structure:

Country/Country1 Code1
Country/Country2 Code2

The question is how to perform parsing of incoming callerid(num) field using asterisk dialplan functions.
The difficulty is that country code lenght is not a constant…

I’d suggest using it as the extension field in in subroutine, although you could also use the called/caller notation to match it without making it an extension.

Do you mean:
Set (CALLERID(name)=country1)

Set (CALLERID(name)=country2)

Looks like this can solve my task, will try it.