Replace NULL values in an array in PostgreSQL
SELECT ARRAY[1,2,3] - ARRAY[5,NULL,6] I am using contrib _int.sql package for array operations in postgresql 8.4 In the above query there is a NULL in right hand side array. Because of this NULL value, it throws an error: "ERROR: array must not contain nulls" Can anyone help me to remove the null values from the array? Erwin Brandstetter 1) Arrays can contain NULL values in PostgreSQL 8.4+ db=# SELECT ARRAY[5,NULL,6]; array ------------ {5,NULL,6} 2) But you cannot subtract one ARRAY from another in standard PostgreSQL 8.4. db=# SELECT ARRAY[1,2,3] - ARRAY[5,NULL,6]; ERROR: operator does not