Re: Control PhoneNumber Via SQL

2018-05-15 Thread tango ward
On Wed, May 16, 2018 at 9:04 AM, tango ward wrote: > Okay, I figured it out. > > cur_t.execute(""" > SELECT > CASE > WHEN mobilenumber ~'^0[1-9]' > THEN regexp_replace(mobilenumber, '0', '+63') > ELSE mobilenumb

Re: Control PhoneNumber Via SQL

2018-05-15 Thread tango ward
Noted thanks Sir. On Wed, May 16, 2018 at 11:55 AM, David G. Johnston < david.g.johns...@gmail.com> wrote: > On Tuesday, May 15, 2018, tango ward wrote: > >> Ah yeah, the concatenation. I was thinking of using "+" but I can't make >> it work and the documentation says not to use it for psycopg2.

Re: Control PhoneNumber Via SQL

2018-05-15 Thread David G. Johnston
On Tuesday, May 15, 2018, tango ward wrote: > Ah yeah, the concatenation. I was thinking of using "+" but I can't make > it work and the documentation says not to use it for psycopg2. > > Sorry what's bottom-post? I see you did that yesterday. Is there a format > for before making a bottom-post?

Re: Control PhoneNumber Via SQL

2018-05-15 Thread tango ward
Ah yeah, the concatenation. I was thinking of using "+" but I can't make it work and the documentation says not to use it for psycopg2. Sorry what's bottom-post? I see you did that yesterday. Is there a format for before making a bottom-post? On Wed, May 16, 2018 at 11:04 AM, David G. Johnston <

Re: Control PhoneNumber Via SQL

2018-05-15 Thread David G. Johnston
On Tuesday, May 15, 2018, tango ward wrote: > Sorry for bumping this email. > > I would just like to clarify regarding regexp_replace: > > WHEN mobilenumber ~'^9[0-9]' AND LENGTH(mobilenumber) = 10 > THEN regexp_replace(mobilenumber, '', '+63') > > If the pattern is empty '', does this mean that

Re: Control PhoneNumber Via SQL

2018-05-15 Thread tango ward
Sorry for bumping this email. I would just like to clarify regarding regexp_replace: WHEN mobilenumber ~'^9[0-9]' AND LENGTH(mobilenumber) = 10 THEN regexp_replace(mobilenumber, '', '+63') If the pattern is empty '', does this mean that the replacement_string param will be added to the value of

Re: Control PhoneNumber Via SQL

2018-05-15 Thread tango ward
Okay, I figured it out. cur_t.execute(""" SELECT CASE WHEN mobilenumber ~'^0[1-9]' THEN regexp_replace(mobilenumber, '0', '+63') ELSE mobilenumber END FROM studeprofile

Re: Control PhoneNumber Via SQL

2018-05-15 Thread tango ward
Did the CASE Statement produce the other columns Sir? On Wed, May 16, 2018 at 8:53 AM, David G. Johnston < david.g.johns...@gmail.com> wrote: > On Tuesday, May 15, 2018, tango ward wrote: >> >> >> I can access the index 1 of the output list to get the +639078638001. I >> think this has been expl

Re: Control PhoneNumber Via SQL

2018-05-15 Thread David G. Johnston
On Tuesday, May 15, 2018, tango ward wrote: > > > I can access the index 1 of the output list to get the +639078638001. I > think this has been explained already by Sir Adrian in my previous question > about the about being shown as list. I'll review that. > Last time you had multiple rows...this

Re: Control PhoneNumber Via SQL

2018-05-15 Thread tango ward
Hi All, Thanks for the suggestions especially the article for formatting international phone numbers. I also implement the suggestion of Sir Wolfgang: cur_t.execute(""" SELECT mobilenumber, CASE WHEN mobilenumber ~'^0[1-9]' THEN

Re: Control PhoneNumber Via SQL

2018-05-15 Thread tango ward
Hi All, Thanks for the suggestions. I really appreciate it specially the article of formatting international phone numbers. I also tried implementing the suggestion of Wolfgang: cur_t.execute(""" SELECT mobilenumber, CASE WHEN mobilenumber ~'^0[1

Re: Control PhoneNumber Via SQL

2018-05-15 Thread raf
haman...@t-online.de wrote: > >> Hi, > >> > >> 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_le

Re: Control PhoneNumber Via SQL

2018-05-15 Thread Alvaro Herrera
On 2018-May-15, John McKown wrote: > 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. Michael Glaesemann wrote a e.164 datatype yea

Re: Control PhoneNumber Via SQL

2018-05-15 Thread John McKown
On Tue, May 15, 2018 at 4:10 AM, tango ward 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

Re: Control PhoneNumber Via SQL

2018-05-15 Thread hamann . w
>> 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

Control PhoneNumber Via SQL

2018-05-15 Thread tango ward
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')