From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Wojciech Skaba <wojciech(dot)skaba(at)teleadreson(dot)pl> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: update ARRAY of COMPOSITE TYPE of text |
Date: | 2013-05-23 14:28:15 |
Message-ID: | 15573.1369319295@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Wojciech Skaba <wojciech(dot)skaba(at)teleadreson(dot)pl> writes:
> UPDATE directory SET faxes = ARRAY[ROW('11', '2222222', '333'), ROW('44', '555', '666')] WHERE id = 1;
> has failed: (You will need to rewrite or cast the expression) with arrow pointing to ARRAY.
> Does anybody know how to overcome it?
Just like it says, cast the expression:
UPDATE directory SET faxes = ARRAY[ROW('11', '2222222', '333'), ROW('44', '555', '666')]::telephone[] WHERE id = 1;
or if it's more convenient for your app, do it like this:
UPDATE directory SET faxes = ARRAY[ROW('11', '2222222', '333')::telephone, ROW('44', '555', '666')::telephone] WHERE id = 1;
I don't recall at the moment why we allow implicit casting from an
anonymous "record" type to a named composite type but not from record[]
to an array of named composite. There might be a good reason for it,
or just a lack of round tuits.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Thom Brown | 2013-05-23 14:33:38 | Re: Foreign Key violated |
Previous Message | Keith Fiske | 2013-05-23 14:15:09 | Foreign Key violated |