PostgreSQL convert array returned from function to columns

后端 未结 3 565
迷失自我
迷失自我 2020-12-19 01:04

I have a function in PostgreSQL (PLPGSQL) that returns an array containing two elements. When I run a select statement calling the function, I get a column containing the a

3条回答
  •  孤城傲影
    2020-12-19 01:28

    You can't do that. A single array column could have, for example, one array with three elements and another with five elements. If you tried to expand those arrays into individual columns, you'd end up with two rows in a result set that have different numbers of columns and that is not allowed.

    The closest thing available is unnest:

    expand an array to a set of rows

    but that gives you rows rather the columns you want.

提交回复
热议问题