1

I have two columns, material_size (text type) and material_size_temp (text[] array type).

When I ran UPDATE parts SET material_size_temp[0] = material_size; I would get values like [0:0]={".021 x 2.450"} instead of {".021 x 2.450"}.

How do I clone the text type column to text[] array type column?

asked Mar 16, 2015 at 19:11
2
  • Do you want to replace the existing value in material_size_temp (the whole array) or just the first element? Or do you want to prepend the array with the text from material_size? Commented Mar 17, 2015 at 0:03
  • @ErwinBrandstetter Most rows have data (just a single measurement) and some no data. I was just trying to move the data in to an array. Commented Mar 17, 2015 at 14:47

1 Answer 1

3

I was close, unlike JavaScript and PHP it seems PostgreSQL array key numbers start with 1, not 0.

UPDATE parts SET material_size_temp[1] = material_size;
answered Mar 16, 2015 at 19:22
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.