patternsqlMinor
Adding value to int array
Viewed 0 times
arrayintvalueadding
Problem
I looked at the postgres website and to add a integer to a intarray it says int[] + int. I have a int array in a table and I eventually want to insert the array with another value added to it into another table. So testing with a select statement I am not sure where I am messing up.
So a am doing:
What am I missing. It looks just like the postgres website on intarrays from 9.1 postgres.
So a am doing:
SELECT myarray + 9::integer from foo
ERROR: operator does not exist: smallint[] + integerWhat am I missing. It looks just like the postgres website on intarrays from 9.1 postgres.
Solution
Use the concatenation operator
Details in the manual: https://www.postgresql.org/docs/current/9.1/functions-array.html
myarray || 9Details in the manual: https://www.postgresql.org/docs/current/9.1/functions-array.html
Code Snippets
myarray || 9Context
StackExchange Database Administrators Q#173615, answer score: 4
Revisions (0)
No revisions yet.