Re: Control PhoneNumber Via SQL

From: tango ward <tangoward15(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "raf(at)raf(dot)org" <raf(at)raf(dot)org>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Control PhoneNumber Via SQL
Date: 2018-05-16 02:50:42
Message-ID: CAA6wQL+=2n+oL3dazEN63BqQ3+V0ct+=Fhdsp9m59hKC-3UDUg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 source? It does what I want it to do
but I am not sure if that's always the case if pattern param is empty.

On Wed, May 16, 2018 at 9:04 AM, tango ward <tangoward15(at)gmail(dot)com> wrote:

> 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
> ORDER BY lastname
> """)
>
> In my previous SELECT statement, I picked the mobilenumber before running
> a CASE statement to it instead of jumping directly to CASE statement after
> SELECT.
>
> On Wed, May 16, 2018 at 8:59 AM, tango ward <tangoward15(at)gmail(dot)com> wrote:
>
>> Did the CASE Statement produce the other columns Sir?
>>
>> On Wed, May 16, 2018 at 8:53 AM, David G. Johnston <
>> david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>>
>>> On Tuesday, May 15, 2018, tango ward <tangoward15(at)gmail(dot)com> 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 time you have multiple columns...
>>>
>>> David J.
>>>
>>
>>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2018-05-16 03:04:02 Re: Control PhoneNumber Via SQL
Previous Message tango ward 2018-05-16 01:04:38 Re: Control PhoneNumber Via SQL