我期待写的更新语句类似如下:如何使用另一列的当前值动态更新列?
update table set
comments = NVL (null, acknowledgement_status),
acknowledgement_status = 'Acknowledge',
alert_updated_time = sysdate,
acknowledged_by = 'Allen'
where alert_id = 8;
其实,值需要从JSP页面更新。如果用户没有给予评论,则相应acknowledgement_status
用户提供了应更新为comments
。但是从上面的查询,以前acknowledgement_status
被设置为comments
。如何去做这件事?
考虑如下表所示内容:
Alert_ID Acknowledgement_status Comments Alert_updated_time Acknowledged_by
-------- ---------------------- -------- ------------------ ---------------
8 OPEN None AUTO
现在上面的表格内容。 JSP有评论字段的文本框和acknowledgement_status
下拉。当用户将Acknowlegement_status
的评论更改为空白时,我希望将确认状态更新为评论。即:
update table set
comments = NVL (textbox.value, acknowledgement_status),
acknowledgement_status = dropdown.value,
alert_updated_time = sysdate,
acknowledged_by = sessionid.value;
where alert_id = 8;
时textbox.value = null, dropdown.value = 'Acknowledge', sessionid.value = 'Allen'
表得到更新如下:
Alert_ID Acknowledgement_status Comments Alert_updated_time Acknowledged_by
-------- ---------------------- -------- ------------------ ---------------
8 Acknowledge OPEN sysdate Allen
,但我要的是:
Alert_ID Acknowledgement_status Comments Alert_updated_time Acknowledged_by
-------- ---------------------- -------- ------------------ ---------------
8 Acknowledge Acknowledge sysdate Allen
我宁愿写,
update table set
comments = NVL (textbox.value, dropdown.value),
acknowledgement_status = dropdown.value,
alert_updated_time = sysdate,
acknowledged_by = sessionid.value;
where alert_id = 8;
但是,我有计划decode
基于dropdown.value
,我认为如果可以用当前值进行更新会更容易。
帮助表示赞赏。
测试你由以前的'acknowledgement_status'究竟意味着什么? – user75ponic
用户给出的价值是什么?这是“确认”吗? –
@Polppan:由以前的acknowledgement_status我的意思是,这已经是这条update语句之前存在的价值。 – zephyrus