Re: Calculated update - Mailing list pgsql-general

From Bosco Rama
Subject Re: Calculated update
Date
Msg-id 4F5E973F.4060807@boscorama.com
Whole thread Raw
In response to Calculated update  (Bret Stern <bret_stern@machinemanagement.com>)
Responses Re: Calculated update  (Bret Stern <bret_stern@machinemanagement.com>)
List 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.

pgsql-general by date:

Previous
From: Martin Gregorie
Date:
Subject: Re: Matching on keyword or phrases within a field that is delimited with an "or" operator "|"
Next
From: Bret Stern
Date:
Subject: Re: Calculated update