Re: Postgres CTE issues - Mailing list pgsql-sql

From Marc Mamin
Subject Re: Postgres CTE issues
Date
Msg-id B6F6FD62F2624C4C9916AC0175D56D8828BCA89E@jenmbs01.ad.intershop.net
Whole thread Raw
In response to Postgres CTE issues  (Shekar Tippur <ctippur@gmail.com>)
Responses Re: Postgres CTE issues  (Shekar Tippur <ctippur@gmail.com>)
List pgsql-sql
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;"><br /> >            This is what I
amtrying:<br /> ><br /> >             WITH x AS <br /> ><br /> >            (INSERT INTO industry
(name,abbr,description,cr_date,last_upd)<br /> ><br /> >            VALUES ('df','','',now(),now()) returning id)
insertinto sector (name,description,cr_date,last_upd,industry_id) select 's1','',now(),now(),id from x;<br /> ><br
/>>            I get a error:<br /> ><br /> >            ERROR:  insert or update on table "sector" violates
foreignkey constraint "sector_id_fkey"<br /> ><br /> >            DETAIL:  Key (id)=(394) is not present in table
"industry".<br/> ><br /> >            If I execute the insert individually, I am able to insert a record. Wonder
whatI am doing wrong.<br /><br /> Hello,<br /> Defining your FK as deferrable initially deferred should help here.<br
/>regards,<br /><br /> Marc Mamin</div> 

pgsql-sql by date:

Previous
From: "David G. Johnston"
Date:
Subject: Fwd: Postgres CTE issues
Next
From: Shekar Tippur
Date:
Subject: Re: Postgres CTE issues