Inserting values in arrays

From: Robert(dot)Farrugia(at)go(dot)com(dot)mt
To: pgsql-sql(at)postgresql(dot)org
Subject: Inserting values in arrays
Date: 2005-03-14 17:53:03
Message-ID: OF96764BBA.060DB4E6-ONC1256FC4.0061C3D4-C1256FC4.00623B75@go.com.mt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I have the following issue.

Given the following tables:

CREATE TABLE test ( details varchar[]);
CREATE TABLE test2 ( textvalue1 varchar, textvalue2 varchar);
INSERT INTO test2 VALUES ('Hello1', 'World1');
INSERT INTO test2 VALUES ('hello2', 'World2');

I would like to insert a row in test for each row of the test2 table i.e.
INSERT INTO test (details) SELECT test2.textvalue1, test2.textvalue2 FROM
test2

and I am expecting the following rows in test
{'Hello1', 'World1'}
{'Hello2', 'World2'}

The above syntax is giving an error. How can this be done in postgres ?

Postgres version I am using is 7.3.4

Regards
Robert

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message lucas 2005-03-14 18:15:55 Generic Function
Previous Message Lance Peterson 2005-03-14 17:31:20 Re: How to cast VARCHAR to BYTEA and vice-versa?