X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 1ADC89F9CAA for ; Tue, 13 Jun 2006 02:30:21 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 24105-10 for ; Tue, 13 Jun 2006 02:30:15 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from weatherbeeta.com.au (mail.weatherbeeta.com.au [202.154.127.242]) by postgresql.org (Postfix) with SMTP id B70039F9316 for ; Tue, 13 Jun 2006 02:30:14 -0300 (ADT) Received: (qmail 30718 invoked from network); 13 Jun 2006 05:30:07 -0000 X-NetworkBox-HamSign: 0101;OUT;wbeetaau1;a0ca275ef21acc976cb34bdb501c6b00; Received: from mail.weatherbeeta.com.au (HELO wb-email) (172.20.0.2)by network-box.weatherbeeta.com.au with SMTP; 13 Jun 2006 05:30:07 -0000 Received: from IT-PHIL ([172.20.0.155]) by wb-email (602Pro LAN SUITE 2003) id 2d52ea36 for pgsql-sql@postgresql.org; Tue, 13 Jun 2006 15:27:59 +1000 Reply-To: From: "Phillip Smith" To: Subject: Re: COPY to table with array columns (Longish) Date: Tue, 13 Jun 2006 15:29:35 +1000 Organization: Weatherbeeta P/L Message-ID: <009801c68eaa$5bf73530$9b0014ac@ITPhil> MIME-Version: 1.0 Content-Type: text/plain;charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 Importance: Normal In-Reply-To: X-Scanned-By-wbeetaau1: Virus scan performed by network-box X-Scanned-By-wbeetaau1: Scanner file id is wbeetaau1-1150176607.129-30694-000 X-Scanned-By-wbeetaau1: No known viruses found in message (received+scanned in 0.02/0.43 secs) X-Scanned-By-wbeetaau1: Spam-Check-Result: No, hits=0 required=7 tests= autolearn=no version=2.0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/131 X-Sequence-Number: 25367 Not quite... ZKCOST and ZPRECMPL are two completely different things. = They have no relation except they're both stored in the SYS table in D3. If we put it in a tree: SYS | +- ZKCOST | \- | +- ZPRECMPL | +- | +- | +- | \- or table: SYS +-----------+---------+---------+---------+---------+ | ZKCOST | | | | | | ZPRECMPL | | | | | +-----------+---------+---------+---------+---------+ So other than a variable-element array, the only other way would be to create a table with a column count equal to or greater than the maximum amount of values (call that value 'Y') that any sys item holds then if a particular record (eg, ZKCOST) has less values than Y, fill the rest of = the columns with blanks (as above). That's what I've done at the moment, but only for 9 columns, so anything over 9 fields will be truncated past and including field 10: wbau=3D# \d sys Table "public.sys" Column | Type | Modifiers --------+------+----------- a0 | text | not null a1 | text | a2 | text | a3 | text | a4 | text | a5 | text | a6 | text | a7 | text | a8 | text | a9 | text | Indexes: "id" PRIMARY KEY, btree (a0) a0 =3D primary key - eg, ZPRECMPL or ZKCOST -----Original Message----- From: pgsql-sql-owner@postgresql.org = [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Aaron Bono Sent: Tuesday, 13 June 2006 2:12 PM To: pgsql-sql@postgresql.org Subject: Re: [SQL] COPY to table with array columns (Longish) I think two tables should suffice: ZKCOST and ZPRECMPL. So you would have ZKCOST zkcost_id, zkcost_value and ZPRECMPL zkcost_id, zprecmpl_id, zprecmpl_value where zkcost_id is the primary key for ZKCOST and zkcost_id, zprecmpl_id together are the primary key for ZPRECMPL and zkcost_id is a foreign key from ZPRECMPL to ZKCOST. That will work won't it? -Aaron On 6/12/06, Phillip Smith wrote: > So you're suggesting creating a child table for each SYS record? Ie, a table called "ZPRECMPL" etc? ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq *******************Confidentiality and Privilege Notice******************* The material contained in this message is privileged and confidential to the addressee. If you are not the addressee indicated in this message or responsible for delivery of the message to such person, you may not copy or deliver this message to anyone, and you should destroy it and kindly notify the sender by reply email. Information in this message that does not relate to the official business of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta. Weatherbeeta, its employees, contractors or associates shall not be liable for direct, indirect or consequential loss arising from transmission of this message or any attachments