【问题标题】:Oracle SQL If statement using select to compare [duplicate]Oracle SQL If语句使用select进行比较[重复]
【发布时间】:2013-11-23 14:48:41
【问题描述】:

我正在尝试比较一个需要从表中检索以执行触发器的数字。

IF (Select *my table* from *column* where *condition*) < 1
then (something)
else (something)

但是当它编译时,我得到以下错误。

错误(2,8):PLS-00103:在预期以下情况之一时遇到符号“SELECT”:(-+ case mod new not null others avg count current exists max min prior sql stddev sum variance execute forall merge时间 时间戳 间隔 日期 管道

我使用 select 来检索金额进行检查是错误的吗?请指教。

【问题讨论】:

  • 如果您想在 dbms 端执行此操作,请阅读 pl-sql,否则在您的应用程序中创建逻辑。

标签: sql oracle


【解决方案1】:
number cnt := 0;
Select count(*) into val from mytable where *condition*;
if val > 0 then
(something)
else 
 (something)
end if;

这是需要的逻辑。

【讨论】:

    猜你喜欢
    • 2016-03-08
    • 2010-09-13
    • 2013-07-19
    • 2016-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-23
    相关资源
    最近更新 更多