Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VfHq0-0007lW-RG for pgsql-sql@arkaria.postgresql.org; Sat, 09 Nov 2013 23:21:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VfHpz-0000q2-Jd for pgsql-sql@arkaria.postgresql.org; Sat, 09 Nov 2013 23:21:07 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VfHpy-0000pw-Oa for pgsql-sql@postgresql.org; Sat, 09 Nov 2013 23:21:06 +0000 Received: from mail-ee0-x232.google.com ([2a00:1450:4013:c00::232]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VfHpt-0007R8-Gh for pgsql-sql@postgresql.org; Sat, 09 Nov 2013 23:21:03 +0000 Received: by mail-ee0-f50.google.com with SMTP id b45so1712573eek.9 for ; Sat, 09 Nov 2013 15:21:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=Mo2fh23vs+ypOw9UApz+kl49mVLQAO2xGy99vDig3XE=; b=LqBgitJdXY5grWROPmPi8uBbBLym41PLcQ6kEUXg6IxRWYVpf5nJnsO3dhUlxK16+1 eXYZ1YqPfs2uw9Bp4VBdB+6t9RF54Z2od/QzxEiB9Qgb/e9LmS2VcFx3H3mVKcxGPeUZ 9lB7L99SpTEL6q7FOzwpiaMZY8xQZgemtfIulaCW+5oaHFK3NPOa5CHeWRojnElqlTWN xIs61qb/IzjKxzAz5HSzeddx1cb3r0Dr94nB7Y5n3CnEqG7xGEi4lbpPcrPxfusvuH4L y77VJSVmXApJuVkXXI3C6yi+VEbfdiw0MDwseKdpGzFJOjBEwhVupqH1Wfm2TmSUFtQR xIdw== X-Received: by 10.14.5.133 with SMTP id 5mr108617eel.84.1384039260208; Sat, 09 Nov 2013 15:21:00 -0800 (PST) Received: from [192.168.178.35] (byrt-4dbfe04b.pool.mediaWays.net. [77.191.224.75]) by mx.google.com with ESMTPSA id z2sm41810785eee.7.2013.11.09.15.20.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 09 Nov 2013 15:20:59 -0800 (PST) Message-ID: <527EC35B.6000809@gmail.com> Date: Sun, 10 Nov 2013 00:20:59 +0100 From: Michael Schmidt User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: How to script inserts where id is needed as fk References: <527D3F2A.6060504@gmail.com> <05069440-C45F-4763-81A8-E14B5CB1CCB5@excoventures.com> <527E968E.8010807@gmail.com> <1384034116071-5777610.post@n5.nabble.com> In-Reply-To: <1384034116071-5777610.post@n5.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -0.9 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Am 09.11.2013 22:55, schrieb David Johnston: > Michael Schmidt-2 wrote >> To extend my scenario a little bit i have a third level called >> 'Incredient' and they need the Article id. I dont think this will work >> anymore with the with clause. Any new approaches? > Why don't you just use a procedural language function? plpgsql should be > sufficient for most requirements. > > David J. > > > > > -- > View this message in context: http://postgresql.1045698.n5.nabble.com/How-to-script-inserts-where-id-is-needed-as-fk-tp5777525p5777610.html > Sent from the PostgreSQL - sql mailing list archive at Nabble.com. > > My solution will be using select currval('atricle_id_seq') for the script. PL/pgSQL will be the nicer solution cause you can store the id and you dont need to select it all the time. Thanks all! -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql