0

テーブル内のレコードをコピーしようとしていますが、MS Access で ID を変更するとエラーが発生します

"SQL error: [Microsoft][ODBC Microsoft Access Driver] The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again., SQL state 23000 in SQLExecDirect"

SQL スクリプトは次のとおりです。

$hh_copy = "insert into hh (rank_id,entry,R_date,fdp_code,village_code,Fname,Sname,gender,age,OI_num,id_num,HH_idnum,Alt_idnum,HH_name,HH_gender,HH_age,T_type,T_cat,hf5,hf18,hf59,hf60,hm5,hm18,hm59,hm60,hhsize,village_name,address,art_num,activate);

SELECT hh.rank_id,hh.entry,hh.R_date,hh.fdp_code,hh.village_code,hh.Fname,hh.Sname,hh.gender,hh.age,hh.OI_num,'" . $new_id ."',hh.HH_idnum,hh.Alt_idnum,hh.HH_name,hh.HH_gender,hh.HH_age,hh.T_type,hh.T_cat,hh.hf5,hh.hf18,hh.hf59,hh.hf60,hh.hm5,hh.hm18,hh.hm59,hh.hm60,hh.hhsize,hh.village_name,hh.address,hh.art_num,hh.activate FROM hh WHERE hh.id_num = '" . $csv_line[0] ."'";
4

0 に答える 0