項目測試過程發現,公司測試無問題,客戶測試報錯,經過現場分析,發現爲plsql中編寫批量插入語句,
沒有明確指明表的字段導致。
因爲客戶端數據表的字段順序和公司數據庫表字段順序不一致導致。
-1400- 位置=,ORA-01400: cannot insert NULL into ("PMSDATA"."TFZ_GRADE_DETAIL_REC_HIS"."SCORE") stpb_id=3901430
原因:公司tfz_grade_detail_rec_his字段的順序和平安不一致,導致不能插入正確值。
insert into tfz_grade_detail_rec_his
select v_id,
x.grin_id,
x.supply_id,
x.user_id,
x.score,
x.remark,
sysdate
from tfz_grade_user_result x
where x.stpb_id = i_stpb_id
and x.stpr_id = i_stpr_id
and x.bundle_code = i_bundle_code
and x.user_id = v.user_id;
公司
batch_id NUMBER(9) not null,
grin_id NUMBER(9) not null,
supply_id NUMBER(9) not null,
user_id NUMBER(9) not null,
score NUMBER(5,2) not null,
remark VARCHAR2(4000),
cdate DATE default sysdate not null
平安
(
BATCH_ID NUMBER(9) not null,
GRIN_ID NUMBER(9) not null,
SUPPLY_ID NUMBER(9) not null,
USER_ID NUMBER(9) not null,
REMARK VARCHAR2(4000),
SCORE NUMBER(5,2) not null,
CDATE DATE default sysdate not null
)
更改:
insert into tfz_grade_detail_rec_his
(batch_id,grin_id,supply_id,user_id,score,remark,cdate)
select v_id,
x.grin_id,
x.supply_id,
x.user_id,
x.score,
x.remark,
sysdate
from tfz_grade_user_result x
where x.stpb_id = i_stpb_id
and x.stpr_id = i_stpr_id
and x.bundle_code = i_bundle_code
and x.user_id = v.user_id;
指明要插入的表字段,是個好習慣,更規範。
深入分析:
導致公司和客戶端表字段順序不一致的原因是tfz_grade_detail_rec_his表之前已經客戶數據庫中,通過後續ddl更改,導致
表字段兩邊順序不一致。因此如果對原始表更改較大,或許先drop掉重新建表會好點。