【问题标题】:Use SELECT inside an IF statement [duplicate]在 IF 语句中使用 SELECT [重复]
【发布时间】:2015-01-03 14:15:56
【问题描述】:

我想要这样的查询:

 if ((select closedatetime from tbl_eventschedularmaster where eventid=p_EventId)> sysdate)
 then
     update tbL_ANSWERMASTER set AnsText=p_AnsText
      where AnsId=p_checkduplicate RETURNING AnsId INTO p_ReturnVal;
else 
      RETURNING 0 INTO p_ReturnVal;
 end if

但它不工作

【问题讨论】:

标签: oracle if-statement


【解决方案1】:

您需要将其重写为

select closedatetime
  into dtClosedDateTime
  from tbl_eventschedularmaster
  where eventid = p_EventId;

if dtClosedDateTime > sysdate then
  update tbL_ANSWERMASTER
    set AnsText=p_AnsText
    where AnsId=p_checkduplicate
    RETURNING AnsId INTO p_ReturnVal;
else 
  p_ReturnVal := 0;
end if;

分享和享受。

【讨论】:

    猜你喜欢
    • 2020-09-04
    • 1970-01-01
    • 1970-01-01
    • 2012-11-11
    • 1970-01-01
    • 1970-01-01
    • 2010-11-10
    • 2013-05-06
    • 1970-01-01
    相关资源
    最近更新 更多