无法弄清楚如何使阵列的组合,而无需重复。
INPUT is an array of n variables LIKE '{A,B,C,D,E}'
Variable A is always single array LIKE '{"A"}' or '{"D,C"}' or '{"D,A,B"}' etc..
What I need is to combine INPUT with A(i)
EXAMPLE:
1. A = '{"B"}' --> att='{"B,A","B,C","B,D","B,E"}'
2. A = '{"B,C"}' --> att='{"B,C,A","B,C,D","B,C,E"}'
3. A = '{"B,C,A"}' --> att='{"B,C,A,D","B,C,A,E"}'
4. A = '{"B,C,A,D"}' --> att='{"B,C,A,D,E"}'
至于我有这样的:
WITH A(i) AS (SELECT * FROM unnest(ARRAY['A,B'])),
B(j) AS (SELECT * FROM unnest(ARRAY['A','B','C','D'])),
cte AS ( SELECT A.i ||','|| B.j
FROM A
CROSS JOIN B
)
SELECT ARRAY ( SELECT * FROM cte) INTO att;
但它使口是心非:
"{"A,B,A","A,B,B","A,B,C","A,B,D"}"