Re: Updating Arrays

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Bob Pawley <rjpawley(at)shaw(dot)ca>
Cc: Postgresql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Updating Arrays
Date: 2011-08-23 02:05:07
Message-ID: CAHyXU0y+mHf-nO85O1kKzAPt4LqYHxsv7iTPoKuccDmkXHK4Eg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> -----Original Message----- From: Merlin Moncure
> Sent: Monday, August 22, 2011 11:03 AM
> To: Bob Pawley
> Cc: Postgresql
> Subject: Re: [GENERAL] Updating Arrays
>
> On Mon, Aug 22, 2011 at 12:54 PM, Bob Pawley <rjpawley(at)shaw(dot)ca> wrote:
>>
>> Hi
>>
>> I exploring the use of arrays.
>>
>> So far I have created a table and inserted a row and updated the row with
>> an
>> array
>> Update library.compare
>>  set _base =
>>  '{2, 0.764149497122068, 4.8886}'
>>  where process_id = 2;
>> – successfully.
>>
>> However when I attempt to update a specific element of the array
>>
>> Update library.compare
>> set _base[2] =
>> '{2}'
>> where process_id = 2;
>> I get an error “invalid input syntax for type numeric: "{2}"”
>
> try "set base[2]  = 2"
>
On Mon, Aug 22, 2011 at 8:49 PM, Bob Pawley <rjpawley(at)shaw(dot)ca> wrote:
> I'm not sure what you mean.
>
> _base -- not base -- is the column name.

oops. anyways, the important point is on the right side of the equals sign.

Update library.compare set _base[2] = 2 where process_id = 2;

(also, please try to avoid top posting)

merlin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2011-08-23 02:12:20 Re: Updating Arrays
Previous Message Bob Pawley 2011-08-23 01:49:48 Re: Updating Arrays