2012-04-30 6 views
0

私はテーブルchapterassociationrgn_nochp_cdの値にテーブルbuergn_nochp_cdの値を更新するクエリを作成しようとしています。私は、WHERE句が問題だとは思わないが、私はそれを実行すると、私は次のエラーを取得しています:PostgreSQLデータベース - エラー・アシスタンス

SQLエラー:

ERROR: insert or update on table "bue" violates foreign key constraint "bue_chp_cd_fkey" 
DETAIL: Key (chp_cd)=(CA3) is not present in table "chapter". 

どのような援助が大幅に高く評価されます!

SQLクエリ:

ERROR: insert or update on table "bue" violates foreign key constraint 
"bue_chp_cd_fkey" DETAIL: Key (chp_cd)=(CA3) is not present in table "chapter". 

それはあなたの更新プログラムの一つが 'CA3' にchp_cdを設定したいが、それCA3が許容値ではないことを言う:

UPDATE bue SET 
rgn_no = chapterassociation.rgn_no, 
chp_cd = chapterassociation.chp_cd 
FROM 
chapterassociation 
WHERE 
bue.mbr_no IS NULL AND bue.chp_cd IS NULL 
AND bue.work_state = chapterassociation.work_state 
AND bue.bgu_cd = chapterassociation.bgu_cd 

答えて

3

はエラーメッセージを読みます"外字キーの制約により、値" CA3 "がテーブル" chapter "に存在することが必要なので、これですべてです。

クエリの構文に何も問題はありません。データモデル内の制約と競合するデータ。

+0

ありがとうございます!私の愚かな間違いで申し訳ありません! – user1364769

関連する問題