我收到此错误:
LINE/COL ERROR
-------- -----------------------------------------------------------------
13/3 PL/SQL: Statement ignored
13/13 PLS-00306: wrong number or types of arguments in call to 'JOIN_JT'
使用的类型:
CREATE TYPE join_t IS OBJECT (
inn NUMBER(38),
out NUMBER(38)
);
/
CREATE TYPE join_jt IS TABLE OF join_t;
/
以下是返回错误的函数的PL / SQL代码。当我尝试将结果传递到join_table
到retval
时,会触发上面的类型错误):
CREATE OR REPLACE FUNCTION join RETURN join_jt
AS
CURSOR cur_fv_table IS SELECT id,fv FROM london WHERE id <= 3000;
retval join_jt := join_jt ();
var_fv london.fv%type;
var_id london.id%type;
join_table join_jt := join_jt();
BEGIN
OPEN cur_fv_table;
LOOP
FETCH cur_fv_table INTO var_id,var_fv;
SELECT join_t(r.id, var_id) BULK COLLECT INTO join_table
FROM london r
WHERE manh_dist(r.fv,var_fv) <= 5;
retval.EXTEND;
retval := join_t(join_table);
END LOOP;
RETURN join_table;
END;
/
您可以使用此功能测试上述功能:
CREATE OR REPLACE FUNCTION manh_dist(
fv1 LONDON.FV%TYPE,
fv2 LONDON.FV%TYPE
) RETURN NUMBER
AS
BEGIN
RETURN 0; -- Implement this.
END;
/
有谁知道如何解决这个错误?
我正在使用Oracle 11g。
答案 0 :(得分:1)
所以这是你的问题:
#pragma once
#include <iostream>
#include <string>
class car{
public:
car();
car(std::string, std::string, int);
int get_cost();
std::string get_brand();
std::string get_color();
private:
std::string newbrand;
std::string newcolor;
int newcost;
};
您正在尝试将表格转换为对象类型。哪个错了。要填充输出表,需要将查询集合与返回集合合并。 MULTISET UNION是您所需要的:
retval := join_t (join_table);
注意:我假设你真的想要返回聚合集合CREATE OR REPLACE FUNCTION knn_join RETURN join_jt
IS
CURSOR cur_fv_table IS SELECT id,fv FROM londonfv WHERE id <= 3000;
retval join_jt := join_jt ();
var_fv londonfv.fv%type;
var_id londonfv.id%type;
join_table join_jt := join_jt();
BEGIN
OPEN cur_fv_table;
LOOP
FETCH cur_fv_table INTO var_id,var_fv;
SELECT join_t(r.id, var_id) BULK COLLECT
INTO join_table FROM londonfv r WHERE manhattan_dist(r.fv,var_fv) <=5;
retval := retval multiset union all join_table;
END LOOP;
RETURN retval;
END;
/
而不是最后一个中间集。
现在没有时间对此进行测试,我承认@Wernfried已经让我怀疑这是否会运行。如果遇到问题,这种更直率的方法将起作用:
retval
答案 1 :(得分:1)
您正在犯的错误是存储结果。查看我的评论内联
retval:= join_t(join_table);
map.addLayer({
'id': 'walking-line',
'type': 'line',
'source': 'walking',
'layout': {
'line-join': 'round',
'line-cap': 'round'
},
'paint': {
'line-color': '#088',
'line-width': 5
}
});