Re: update field using substrings of another field

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Doug McNaught <doug(at)mcnaught(dot)org>
Cc: "Dave [Hawk-Systems]" <dave(at)hawk-systems(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: update field using substrings of another field
Date: 2003-09-16 14:36:22
Message-ID: 17149.1063722982@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Doug McNaught <doug(at)mcnaught(dot)org> writes:
> "Dave [Hawk-Systems]" <dave(at)hawk-systems(dot)com> writes:
>> Have a table with fnumber and number, both text
>> fnumber is a phone number, format "8005551212"
>> number needs to be the same number but in the format "(800) 555-1212"

> You could do it fairly easily with a trigger.

Or consider plan B: why bother to actually store "number" at all,
if it is trivially computable from "fnumber"?

You could make a view that includes "number" as a derived column,
if you have apps that insist on seeing it as an ordinary-looking
column in the select result.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Edwin Quijada 2003-09-16 14:41:58 Re: 4D to PostgreSQL tools
Previous Message scott.marlowe 2003-09-16 14:24:18 Re: CONCAT function