create or replace function isExist(data in DataTypes)  --DataTypes 为表中该数据的类型
return Number
is
v_flag number(2);
v_data [DataTypes]; --表中数据的类型
begin
select data into v_data from table_name where ....;
if v_data not null then
v_falg := 1;
else
v_flag :=0;
end if;
return v_falg;
Exception
when DATA_NOT_FOUND then
v_falg :=0;
return v_falg;
when OTHERS then
v_flag := -1;
return v_falg;
end;

--返回0不是该数据不存在
--返回1表示该数据存在
--返回-1表示sql语句有问题
--可能不需要if判断,但为了保险,加了一句,可能是多余的代码。

相关文章:

  • 2021-12-31
  • 2021-10-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-27
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
  • 2022-01-26
相关资源
相似解决方案