无法在另一个程序内调用存储过程

时间:2014-04-17 06:38:18

标签: sql oracle oracle10g

我有这个程序:

PROCEDURE insert_change_history(
  client_number_l           history.client_number%TYPE,
  change_date_l             history.change_date%TYPE,
  field_name_l              history.field_name%TYPE,
  new_value_l               history.new_value%TYPE,
  action_performer_l        history.action_performer%TYPE

) AS

  old_value_l              history.old_value%TYPE;

  BEGIN

    SELECT new_value into old_value_l from history;

    IF old_value_l = new_value_l THEN CALL load_client_numbers();

    END IF

END insert_change_history;

正如您所看到的,我正在尝试在if语句中调用load_client_numbers(),但它无效。我收到以下错误:

Error(4017,44): PLS-00103: Encountered the symbol "LOAD_CLIENT_NUMBERS" when expecting one of the following:     := . ( @ % ; The symbol ":=" was substituted for "LOAD_CLIENT_NUMBERS" to continue. 
Error(4022,1): PLS-00103: Encountered the symbol "END" when expecting one of the following:     ; The symbol ";" was substituted for "END" to continue. 

以下是load_client_numbers()

PROCEDURE load_client_numbers(
 result_o                    OUT CLOB 
) AS
  l_data                                     hub_cursor;

  number_l            plan.client_number%TYPE;
  name_l              details.client_name%TYPE;

  l_jsonArray           json_list;
  l_jsonObj             json;
  l_obj_out             json;
  BEGIN
  OPEN l_data FOR

   SELECT DISTINCT rp.number, cd.name
   FROM plan rp
   FULL JOIN details cd ON rp.number = cd.number
   ORDER BY number;

    l_jsonArray := json_list();

    LOOP
      FETCH l_data INTO
         number_l, name_l; 
    EXIT WHEN l_data%NOTFOUND;

      l_jsonObj := json();
      l_jsonObj.put('Number', number_l || '/' || client_name_l);
     -- l_jsonObj.put('Name', name_l);

      l_jsonArray.append(l_jsonObj.to_json_value);

    END LOOP;
    CLOSE l_data;

    l_obj_out := json();
    l_obj_out.put('data',l_jsonArray);    
    result_o := ' ';
    l_obj_out.to_clob(result_o);

END load_client_numbers;

为什么我会收到错误?我知道我错过了一些非常小的东西,但我无法发现它,因为我不是甲骨文的专家。

1 个答案:

答案 0 :(得分:4)

代码应该像

IF old_value_l = new_value_l THEN load_client_numbers(param);
END IF;

(没有CALL) 其中param是一个clob。