Skip to content
Advertisement

How to handle cases where array is empty in postgresql?

I have a function written in plpythonu.

On some cases when t_x is empty i get an error:

ERROR: cannot determine type of empty array

How do I fix it?

Advertisement

Answer

if-else statement

Pseudocode:

cast

Why cast help?

array[1,2] has type integer[]


array[] has no type.


array[]::integer[] has type integer[]

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement