postgresql/contrib/array/README.array_iterator

32 lines
1 KiB
Text
Raw Normal View History

Array iterator functions have been removed as of PostgreSQL 7.4, because
equivalent functionality is now available built in to the backend.
2000-06-19 10:02:16 -04:00
For example, previously, using contrib/array, you might have used the
following construct:
2000-06-19 10:02:16 -04:00
create table t(id int4[], txt text[]);
2000-06-19 10:02:16 -04:00
-- select tuples with some id element equal to 123
select * from t where t.id *= 123;
2000-06-19 10:02:16 -04:00
Now you would do this instead:
2000-06-19 10:02:16 -04:00
-- select tuples with some id element equal to 123
select * from t where 123 = any (t.id);
2000-06-19 10:02:16 -04:00
-- or you could also do this
select * from t where 123 = some (t.id);
2000-06-19 10:02:16 -04:00
Similarly, if using contrib/array, you did the following:
2000-06-19 10:02:16 -04:00
-- select tuples with all txt elements matching '^[A-Z]'
select * from t where t.txt[1:3] **~ '^[A-Z]';
2000-06-19 10:02:16 -04:00
Now do this instead:
2000-06-19 10:02:16 -04:00
-- select tuples with all txt elements matching '^[A-Z]'
select * from t where '^[A-Z]' ~ all (t.txt[1:3]);
2000-06-19 10:02:16 -04:00
2003-09-13 13:33:46 -04:00
See this section in the PostgreSQL documentation for more detail:
The SQL Language => Functions and Operators => Row and Array Comparisons