1

I am inserting the array of elements {idno,age,salary} as {1,10000,30} in PostgreSQL database and I need to split and store into the respected columns of the table.

How to store the split array elements in respect columns of table?

First is this possible , if possible can some one explain me ,how can we do it?

mu is too short
  • 426,620
  • 70
  • 833
  • 800
Kanchetianeel
  • 189
  • 2
  • 3
  • 15
  • So you have an array containing those three numbers inside PostgreSQL and you want to `update ... set idno=1, age=10000, salary=30` on some table? – mu is too short Dec 19 '13 at 06:16
  • Thank you,i am inserting the array of elements in respected columns on some table.and those three numbers inserted in their respected columns. – Kanchetianeel Dec 19 '13 at 06:24

1 Answers1

4

Like this?

insert into test(idno, age, salary)
select D[1], D[2], D[3]
from (select '{1,10000,30}'::int[]) as A(D);

sql fiddle demo

Roman Pekar
  • 107,110
  • 28
  • 195
  • 197