Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 7BA5D9FB473 for ; Thu, 3 May 2007 16:26:53 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 30474-07 for ; Thu, 3 May 2007 16:26:47 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from web31809.mail.mud.yahoo.com (web31809.mail.mud.yahoo.com [68.142.207.72]) by postgresql.org (Postfix) with SMTP id 5FA529FB3E1 for ; Thu, 3 May 2007 16:26:49 -0300 (ADT) Received: (qmail 10343 invoked by uid 60001); 3 May 2007 19:26:43 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=Q62Qm4jfX2wTt7JoYxNnl8om4V629QYWzb+l6w+nl1Y0YvfYNpqr9dMuGw+CwmW6Cs1bZySGCMOYxzQEoX/tL44mFuCF6Vhfoz2GrmBIVkSfO/pPkM1Lm8q791TeKp1F4DwSOfVg6iwf9+4nbyeWSOq7tAYgi5WK37i+eMYL8/A=; X-YMail-OSG: l6dRC34VM1kHURQl6p9AQgJpo6S0PHSD18ByGddCiIDPxZ3P5NuXC75rkP403wHgwPQ9Ug-- Received: from [63.203.180.122] by web31809.mail.mud.yahoo.com via HTTP; Thu, 03 May 2007 12:26:42 PDT Date: Thu, 3 May 2007 12:26:42 -0700 (PDT) From: Richard Broersma Jr Subject: Re: Insert into VIEW using RULE. Not possible to use nextval()? To: Collin Peters Cc: pgsql-sql@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <13300.9416.qm@web31809.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.429 tagged_above=0 required=5 tests=AWL=-0.816, BAYES_05=-1.11, DNS_FROM_RFC_ABUSE=0.2, DNS_FROM_RFC_POST=1.708, DNS_FROM_RFC_WHOIS=1.447 X-Spam-Level: * X-Archive-Number: 200705/20 X-Sequence-Number: 28301 --- Collin Peters wrote: > The exact problem is that you can't use nextval() with an INSERTable VIEW I apoligize if I am not understanding your problem correctly. I am unsure as to intent behind using nextval() as opposed to currval(). I do not know if the following DDL will help but I can show you how I preform inserts across multiple tables using the rule system: CREATE RULE Vschematic_insert AS ON INSERT TO Docs.Vschematic DO INSTEAD ( INSERT INTO Docs.Document ( did, doccode, docnum, docdisc) VALUES ( DEFAULT, 'schematic', New.docnum, New.docdisc); INSERT INTO Docs.Drawing ( did, doccode, title1, title2, title3) VALUES ( Currval('Docs.Document_did_seq'), 'schematic', New.title1, New.title2, New.title3); INSERT INTO Docs.Schematic ( did, doccode) VALUES ( Currval('Docs.Document_did_seq'), 'schematic') ); For reference the table DDL follows: CREATE TABLE docs.document ( did serial PRIMARY KEY, doccode varchar(30) not null, docnum varchar(30) unique not null, docdisc text not null default '', constraint document_doccode_chk check ( doccode in ( 'cpf', 'logicsystem', 'processdetail', 'electricaldetail', 'locationplan', 'logicdiagram', 'loopdiagram', 'schematic', 'wiringdiagram', 'pid', 'isometric', 'airsupplydetail', 'mountingdetail', 'pnuematicdetail', 'functionaldiscription', 'datasheet', 'processmaterialspec', 'loopfoldermiscellaneous', 'loopfolderorficeplate', 'loopfolderinstallation', 'loopfolderswitch', 'loopfolderxmtrctrlind', 'loopfoldercontrolvalve', 'loopfolderanalyzer', 'loopfolderworkscope', 'loopfolderdocumentation'))); CREATE TABLE docs.drawing ( did integer primary key references docs.document(did) on delete cascade, doccode varchar(30) not null, title1 varchar(50) not null, title2 varchar(50) not null, title3 varchar(50) not null, constraint drawing_doccode_chk check ( doccode in ( 'processdetail', 'electricaldetail', 'locationplan', 'logicdiagram', 'loopdiagram', 'schematic', 'pid', 'isometric', 'airsupplydetail', 'mountingdetail', 'pnuematicdetail'))) ; CREATE TABLE docs.schematic ( did integer primary key references docs.drawing(did) on delete cascade, doccode varchar(30) not null, cid integer references equ.lcp(cid), constraint schematic_doccode_chk check ( doccode = 'schematic')) ; Regards, Richard Broersma Jr.