我正在寻找如下所示的更新语句:
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
评论更改为空白时,我希望将确认状态更新为评论。IE:
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
,我认为如果可以用当前值更新会更容易。
帮助表示赞赏。