targetted array element modification or delete without knowing the index?

From: "Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: targetted array element modification or delete without knowing the index?
Date: 2009-12-24 18:01:45
Message-ID: 482E80323A35A54498B8B70FF2B879800438374E8C@azsmsx504.amr.corp.intel.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Is there a way to modify or delete an element of an array with knowledge only of the element's value? Maybe an array index finder would help?

For example

create table foo (name,text, arr text[]);
insert into foo (name,arr) values ('joe',ARRAY['a','b','c']);

update foo set arr[indexfinder('b')] = 'z';

This would update arr[2], because that's the element with value 'b'

Thanks !

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Broersma 2009-12-24 18:11:04 Re: targetted array element modification or delete without knowing the index?
Previous Message Israel Brewster 2009-12-24 17:42:32 Re: defining yuor own commands in PG ?