Re: Control PhoneNumber Via SQL

From: John McKown <john(dot)archie(dot)mckown(at)gmail(dot)com>
To: tango ward <tangoward15(at)gmail(dot)com>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Control PhoneNumber Via SQL
Date: 2018-05-15 12:29:24
Message-ID: CAAJSdjgWwKwTpGVfaecXq2UkYQRGiZiQ8L3CSnekPyEjUu7xGw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, May 15, 2018 at 4:10 AM, tango ward <tangoward15(at)gmail(dot)com> wrote:

>
> Hi,
>
> Sorry for asking question again.
>
> I would like to know if it is possible to control the phone number in SQL
> before inserting it to the destination DB?
>
> I have a model in Django:
>
> class BasePerson(TimeStampedModel):
> phone_number = PhoneNumberField(max_length=50, verbose_name=_(u'phone
> number'), blank=True)
>
>
> The data for phone number that I am migrating doesn't have country code. I
> want to determine first if the number has country code in it, if it doesn't
> then I will add the country code on the number before INSERTING it to the
> destination database.
>
> Any suggestion will be highly appreciated.
>
>
> Thanks,
> J
>

I don't have any code for you, if that is what you are soliciting. I did
find a couple of informative web sites which help explain how international
phone numbers are formatted. These are known as E.164 numbers.

https://support.twilio.com/hc/en-us/articles/223183008-Formatting-International-Phone-Numbers

https://en.wikipedia.org/wiki/List_of_country_calling_codes#Alphabetical_listing_by_country_or_region

Note that the above mainly talk about how a number is formatted, not on how
to validate that it is an actual phone number. You must trust the end user.
Which is another can of worms. Case in point -- Yesterday I got 6 automated
phone calls from the local cable company to verify some installation. The
problem is, I am not installing anything. The person either gave them a bad
number or mistyped it into a web page or the customer service rep mistyped
it.​

--
We all have skeletons in our closet.
Mine are so old, they have osteoporosis.

Maranatha! <><
John McKown

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2018-05-15 12:53:10 Re: Query ID Values
Previous Message Łukasz Jarych 2018-05-15 12:28:07 Function to set up variable inside it