Re: Calculated update

From: Bosco Rama <postgres(at)boscorama(dot)com>
To: bret_stern(at)machinemanagement(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Calculated update
Date: 2012-03-13 00:39:27
Message-ID: 4F5E973F.4060807@boscorama.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bret Stern wrote:
>
> trying to update a varchar numeric string column
> by converting it to int, adding a numeric value and insert it back
> as a varchar
>
> Having trouble with cast

I assume you are doing an update as opposed to an insert. You use
both above (and both numeric and int as well). Anyway, try:

update tbl set col = (col::int + 1);

or some variation thereof. That should do the trick.

Bosco.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bret Stern 2012-03-13 01:11:34 Re: Calculated update
Previous Message Martin Gregorie 2012-03-13 00:38:04 Re: Matching on keyword or phrases within a field that is delimited with an "or" operator "|"