2

我有一个包含如下函数的包,它需要一个参数是数组。

create or replace PACKAGE selected_pkg IS

TYPE NUM_ARRAY IS TABLE OF NUMBER;

FUNCTION get_selected_kml(
  in_layer        IN NUMBER,
  in_solm_id      IN NUMBER,
  in_feature_ids  IN NUM_ARRAY, 
  in_lx           IN NUMBER,
  in_ly           IN NUMBER,
  in_ux           IN NUMBER,
  in_uy           IN NUMBER)
RETURN CLOB;

END selected_pkg;

现在我正在尝试从以下匿名块调用该函数:

declare
  result CLOB;
  TYPE NUM_ARRAY1 IS TABLE OF NUMBER;
  myarray NUM_ARRAY1 := NUM_ARRAY1 ();
begin
  myarray.extend(3);
  myarray(1) := 1;
  myarray(2) := 5;
  myarray(3) := 9;
  EXECUTE IMMEDIATE 'truncate table demoresult';
  result:=SELECTED_PKG.get_selected_kml(103, 19, myarray, 4.11, 56.27, 4.59, 56.39);
  insert into demoresult values(result);
  COMMIT;
end;

我收到错误

PLS-00306:调用“GET_SELECTED_KML”时参数的数量或类型错误

有人可以建议我,我做错了什么?

谢谢, 阿兰卡

4

1 回答 1

4

您需要使用与您的函数所期望的相同的数组类型

declare
  result CLOB;
  myarray selected_pkg.num_array := selected_pkg.num_array();
begin
  myarray.extend(3);
  myarray(1) := 1;
  myarray(2) := 5;
  myarray(3) := 9;
  EXECUTE IMMEDIATE 'truncate table demoresult';
  result:=SELECTED_PKG.get_selected_kml(103, 19, myarray, 4.11, 56.27, 4.59, 56.39);
  insert into demoresult values(result);
  COMMIT;
end;
于 2013-04-26T10:48:25.127 回答