From: Andreas <maps.on@gmx.net>
To: Emre Hasegeli <emre.hasegeli@tart.com.tr>
Cc: pgsql-sql@postgresql.org
Subject: Re: Question on imports with foreign keys
Date: Thu, 08 Dec 2011 11:10:06 +0100
Message-ID: <4EE08CFE.3090209@gmx.net> (raw)
In-Reply-To: <op.v55w0nozk2xoe5@tart-hasegeli-development>
References: <4EE05DD3.2080308@gmx.net>
<op.v55w0nozk2xoe5@tart-hasegeli-development>
Am 08.12.2011 09:39, schrieb Emre Hasegeli:
> On Thu, 08 Dec 2011 08:48:51 +0200, Andreas <maps.on@gmx.net> wrote:
>
>> How is the easiest way to to find the customer.id of the new
>> customers so I can insert the projectinfos?
>>
>
> It is easy to select rows not related with another table. One of the
> following queries can be used.
>
>> Select * from "customers" where id not in (select "customerId" from
>> "projectinfos")
>
I'm sorry I wasn't clear enough describing the scenario.
Lets's say there were already 1000 records in the customers table.
Now I add 357 new customers to this table.
If I use one of your queries I'd get all 1357 entries of customers since
"project_x.projectinfos" would be newly created for this project and
therefor empty.
I need to know which customers.id was created for which line in the
temporary table that I read in with copy.
When I have those ids I can fill "project_x.projectinfos" with just
those new 357 customer.ids and foreign keys refering the new lookup-tables.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: maps.on@gmx.net, emre.hasegeli@tart.com.tr
Subject: Re: Question on imports with foreign keys
In-Reply-To: <4EE08CFE.3090209@gmx.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox