targetted array element modification or delete without knowing the index? - Mailing list pgsql-general

From Gauthier, Dave
Subject targetted array element modification or delete without knowing the index?
Date
Msg-id 482E80323A35A54498B8B70FF2B879800438374E8C@azsmsx504.amr.corp.intel.com
Whole thread Raw
Responses Re: targetted array element modification or delete without knowing the index?  (Richard Broersma <richard.broersma@gmail.com>)
List 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 !

pgsql-general by date:

Previous
From: Israel Brewster
Date:
Subject: Re: defining yuor own commands in PG ?
Next
From: Richard Broersma
Date:
Subject: Re: targetted array element modification or delete without knowing the index?