Fix Error “cannot determine type of empty array” in PostgreSQL

If you’re getting an error that reads “cannot determine type of empty array” in PostgreSQL, it could be that you’re trying to create an empty array without specifying the array type.

It’s impossible to create an array with no type, and so if we want to create an empty array, then we need to specify the type or add items to determine the type.

To fix this issue, either specify the array type for the empty array, or add items to the array.

Continue reading

How ARRAY_FILL() Works in PostgreSQL

In PostgreSQL we can use the array_fill() function to create an array filled multiple instances of a given value.

We pass the value to populate as the first argument, followed by the length of the desired array. The resulting array replicates the first argument as specified by the length in the second argument.

We also have the option of passing a third argument to specify the lower bound values of each dimension of the array.

Continue reading

Fix Error “time field value out of range” when using make_time() in PostgreSQL

If you’re getting an error that reads ‘time field value out of range‘ in PostgreSQL while using the make_time() function, it’s probably because one or more of the time parts you’re providing is out of the accepted range for that time part.

To fix this issue, be sure that each time part you provide is within the valid range for that time part.

Continue reading