Is it possible to bind an array to a name in a SQL statement? I'm looking for something similar to a Lisp/Haskell let-expression.
My first thought was to use a 'with' clause before the select statement that uses the array in a function call.
WITH thenumbers AS ARRAY(SELECT buildingnum FROM numbers WHERE area = 'Bu',
SELECT buildingnum FROM numbers WHERE area = 'Ba',
SELECT buildingnum FROM numbers WHERE area = 'E',
SELECT buildingnum FROM numbers WHERE area = 'O',
SELECT buildingnum FROM numbers WHERE area = 'Mi',
SELECT buildingnum FROM numbers WHERE area = 'Ho',
SELECT buildingnum FROM numbers WHERE area = 'Wa',
SELECT buildingnum FROM numbers WHERE area = 'Wi')
SELECT bnorm(area,preal,thenumbers) FROM electrical_energy;
Two details that might inform an answer are that I'm working with Postgres 8.3 and 'numbers' is a view rather than a table.