我在postgres函数中使用这些语句.
Select count(*) into V_check from employee where employee_name like 'Raj%'; if V_check == 0 then update exception set exception_found = 'Raj'; end if;
我收到此错误:
06001
解决方法
正如所指出的,相等的比较运算符是= not ==.但是,您应该将条件写为:
if not exists (select 1 from employee where employee_name like 'Raj%') then update exception set exception_found = 'Raj'; end if;
这可以为您节省声明.此外,不存在比count(*)更快 – 因为不存在可以在第一个匹配行停止.
或完全免除条件:
update exception set exception_found = 'Raj' where not exists (select 1 from employee where employee_name like 'Raj%');
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。