Re: Control PhoneNumber Via SQL - Mailing list pgsql-general

From John McKown
Subject Re: Control PhoneNumber Via SQL
Date
Msg-id CAAJSdjgWwKwTpGVfaecXq2UkYQRGiZiQ8L3CSnekPyEjUu7xGw@mail.gmail.com
Whole thread Raw
In response to Control PhoneNumber Via SQL  (tango ward <tangoward15@gmail.com>)
Responses Re: Control PhoneNumber Via SQL  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-general
On Tue, May 15, 2018 at 4:10 AM, tango ward <tangoward15@gmail.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.



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

pgsql-general by date:

Previous
From: Łukasz Jarych
Date:
Subject: Function to set up variable inside it
Next
From: Adrian Klaver
Date:
Subject: Re: Query ID Values