X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 49D6332A4BB for ; Tue, 5 Oct 2004 04:56:49 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54163-08 for ; Tue, 5 Oct 2004 03:56:44 +0000 (GMT) Received: from fusion.bennyvision.com (fusion.bennyvision.com [216.161.119.28]) by svr1.postgresql.org (Postfix) with SMTP id B77AC329FB6 for ; Tue, 5 Oct 2004 04:56:43 +0100 (BST) Received: (qmail 28990 invoked from network); 5 Oct 2004 03:56:42 -0000 Received: from localhost (HELO webmail.stinkweasel.net) (127.0.0.1) by fusion.bennyvision.com with SMTP; 5 Oct 2004 03:56:42 -0000 Received: from 63.227.74.41 (SquirrelMail authenticated user benny); by webmail.stinkweasel.net with HTTP; Mon, 4 Oct 2004 22:56:20 -0500 (CDT) Message-ID: <64789.63.227.74.41.1096948602.squirrel@63.227.74.41> Date: Mon, 4 Oct 2004 22:56:20 -0500 (CDT) Subject: Stuffing six separate columns into a single array? From: "C. Bensend" To: pgsql-sql@postgresql.org User-Agent: SquirrelMail/1.4.3a X-Mailer: SquirrelMail/1.4.3a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/23 X-Sequence-Number: 19126 Hey folks, I'm in the middle of a database design update, mostly to undo all of the stupid things I did in version 0.01. :) God knows I made enough of them... I have a table with the following columns: dns1_ptr | inet | default '0.0.0.0'::inet dns2_ptr | inet | default '0.0.0.0'::inet dns3_ptr | inet | default '0.0.0.0'::inet dns4_ptr | inet | default '0.0.0.0'::inet dns5_ptr | inet | default '0.0.0.0'::inet dns6_ptr | inet | default '0.0.0.0'::inet (yes, I know, I didn't know any better) It is being replaced by: dns_ptr | inet[] | default ...etc (hopefully this is more intelligent) Now, as I migrate the data from the old table to the new, is there any way to just do the typical 'INSERT INTO blah SELECT a,b,c FROM blah2' type of thing? ie, INSERT INTO new_table ( dns_ptr ) SELECT dns1_ptr, dns2_ptr .. FROM old_table; I can't seem to get the CASTing right on the SELECT statement, but perhaps it's not even possible. It would be nice to be able to do this so I don't have to write yet another perl script. I thought a 'CAST( '{dns1_ptr, dns2_ptr}' AS inet[] )' would work, but it complained about the input syntax on dns1_ptr. I'm learning as I go, so maybe that's not even close to being valid. Any help/advice would be greatly appreciated, Benny -- "Even if a man chops off your hand with a sword, you still have two nice, sharp bones to stick in his eyes." -- .sig on Slashdot