2 回答
TA贡献1797条经验 获得超4个赞
鉴于您的插入件是:
$insertitem = "INSERT into production (item_identifier,expiration_timestamp)
values (item_identifier,expiration_timestamp)";
$insertComment = "INSERT into productionComment (item_id, comment, comment_type_id)
values (item_id, comment, comment_type_id)";
看起来您正在使用标识列来item_id。您可以使用该函数检索最近生成的标识值,因此第二个插入应为:IDENTITY_VAL_LOCAL()
$insertComment = "INSERT into productionComment (item_id, comment, comment_type_id)
values (IDENTITY_VAL_LOCAL(), comment, comment_type_id)";
TA贡献1829条经验 获得超13个赞
我无法帮助PHP,但是对于IBMi的DB2,您有不同的解决方案:
如果我理解正确,item_id是一个生成总是作为标识列
您可以使用以下命令获取新创建的item_id
select item_id from final table (
INSERT into production (item_identifier,expiration_timestamp)
values (544,'2020-03-01 12:00:00')
)
或者,您可以使用开发值或您自己的增量强制item_id的值
INSERT into production (idtem_id, item_identifier,expiration_timestamp)
values (<your value>, 544,'2020-03-01 12:00:00')
OVERRIDING SYSTEM VALUE
在这种情况下,您必须通过发出为item_id设置下一个值
alter table production alter column item_id restart with <restart value>
- 2 回答
- 0 关注
- 185 浏览
添加回答
举报