Oracle SQL-检查整个表中的重复项

伊姆兰·赫曼尼(Imran Hemani)

我有一张有桌子的桌子

BIN_1_1
BIN_1_2
BIN_1_3

一路走到 BIN_10_10

用户输入一个值,并且需要在从BIN_1_1到BIN_10_10的所有列中检查该值。

如果有重复的值,它将打印一条消息,并退出过程/函数。

我该怎么办?

量子思维

你的意思是这样吗?

create or replace
procedure check_duplicate( p_val yourtable.bin_1_1%type) is
  v_dupl number;
begin
  begin
    select 1 into v_dupl from yourtable
    where p_val in (bin_1_1, bin_1_2, ... bin_10_10) and rownum <=1;
  exception 
     when no_data_found
        then v_dupl := 0;
  end;
  if v_dupl = 1
  then
      dbms_output.put_line('your message about duplication');
      return;
  else
      dbms_output.put_line('here you can do anything');      
  end if;
end;

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章