Let say I have table like this:
+-----+-----------------+-------------+
| ID | Points | BreakPoints |
+-----+-----------------+-------------+
| 123 | {6,8,1,3,7,9} | {1,7} |
| 456 | {16,9,78,96,33} | {78} |
+-----+-----------------+-------------+
I want to "break" these Points sequences on points contained in BreakPoints, while keeping ID of original row. Order of elements in sequence is important, so I cannot sort them!
Also notice, that break points are in both result rows that came from breaking original sequence at that break point (on the end and start respectively). So result should be something like this:
+-----+------------+
| ID | Points |
+-----+------------+
| 123 | {6,8,1} |
| 123 | {1,3,7} |
| 123 | {7,9} |
| 456 | {16,9,78} |
| 456 | {78,96,33} |
+-----+------------+
Of course, I can write PL/pgSQL function, call it for every row, iterate the array and RETURN NEXT for every sub-sequence. But is there any other way, without calling function for all rows?