-1

我有几个名字,如:

john arnold 
edward albert 

我有一个这样的名称字典:

name 
---------------------------  
john   
arnold 
edward 

我编写了一个函数来将名称分成几部分并将每个部分与字典进行比较(因此 edward 与字典进行比较,然后 albert 将与字典进行比较)。

我的问题是我想返回字典中不存在的所有名称的串联字符串,例如,如果名称如下所示:

john albert adam gerard

它应该返回:

adam gerard

我将名称放在一个数组中并像这样搜索它们:

select name into name_base from usr_pre_pub.nd where name=names(ix);

但是,当在字典中找不到名称时,执行将停止并且不会继续分析数组中的以下名称。

john (found)  albert(found) adam (not found, exception no data found) gerard (not analysed)

我已经删除了函数的异常捕获部分:

   exception     
   when no_data_found then
       return ix;
     when others then
     return 'others';
       -- consider logging the error and then re-raise
       raise;

但随后它只是停止并且不返回值。

我不知道从哪里开始,希望你能帮助我解决这个问题。

4

1 回答 1

2

看起来您没有在循环内捕获异常。假设您有一个循环来遍历数组中的每个名称,您的循环应该看起来像这样。

LOOP
   BEGIN
      SELECT name
        INTO name_base
        FROM usr_pre_pub.nd
       WHERE name = names (ix);
   EXCEPTION
      WHEN NO_DATA_FOUND
      THEN
         --store the name in variable/array for returning, as not found
      WHEN OTHERS
      THEN
         --do something else
   END;
END LOOP;
于 2013-06-19T01:33:10.543 回答