无法调用 Oracle 函数 [英] Unable to call an Oracle Function

查看:30
本文介绍了无法调用 Oracle 函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a package with a function in it like following, which expects one of the parameter which is array.

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;

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

Now I am trying to call the function from following anonymous block :

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"时参数的数量或类型错误

PLS-00306: wrong number or types of arguments in call to 'GET_SELECTED_KML'

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

Could someone please suggest me, what am I doing wrong?

谢谢,阿兰卡

推荐答案

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

You need to use the same array type that your function is expecting

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;

这篇关于无法调用 Oracle 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆