我遇到了一些麻烦,在网上搜索时找不到合适的答案。 我正在使用oracle apex 5.1.3,我正在写一些plsql用于全文搜索的报告,但似乎无法应用得分,我知道我犯了一个金发的错误,但我知道基本查询有效。
这是我的原始查询
SELECT VENUE_NAME, CITY, POSTCODE, score(1) + score(2) as score
FROM GAMEVENUE
WHERE
(
CONTAINS(VENUE_NAME, '$FUZZY(plymouth)', 1) > 0
OR CONTAINS(CITY, '$FUZZY(plymouth)', 2) > 0
OR CONTAINS(POSTCODE, 'plymouth') > 0
)
ORDER BY score DESC;
这就是问题所在,任何帮助都会很棒。
解析返回的查询结果为“ORA-06550:第9行,第11列:ORA-29908:缺少辅助运算符的主要调用”。如果您认为您的查询在语法上是正确的,请选中下面的“使用通用列名称”复选框以继续操作而不进行解析。
DECLARE
l_query VARCHAR2 (4096);
BEGIN
l_query := '
select
"VENUE_ID",
"VENUE_NAME",
"CITY",
"VENUE_NO",
"POSTCODE",
dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
score(1) + score(2) as score
FROM "GAMEVENUE" i';
IF v('P2_REPORT_SEARCH') IS NOT NULL THEN
l_query := l_query||' '||'
where
(
contains(VENUE_NAME, ''$fuzzy('|| v('P2_REPORT_SEARCH') ||'), 1'') > 0 or
contains(CITY, ''$fuzzy('|| v('P2_REPORT_SEARCH') ||'), 2'') > 0 or
contains(POSTCODE, '''|| v('P2_REPORT_SEARCH') ||''') > 0
)
ORDER BY score DESC';
END IF;
RETURN l_query;
END;
答案 0 :(得分:0)
ORA-29908: missing primary invocation for ancillary operator
表示您实际上正在运行如下查询:
select
"VENUE_ID",
"VENUE_NAME",
"CITY",
"VENUE_NO",
"POSTCODE",
dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
score(1) + score(2) as score
FROM "GAMEVENUE" i
换句话说,您错过了WHERE
子句,可能是因为这个IF语句:
IF v('P2_REPORT_SEARCH') IS NOT NULL THEN
l_query := l_query||' '||'
where ...
您可能想要做的是,如果没有添加where子句,请避免调用score()
,例如
if v('P2_REPORT_SEARCH') is not null then
l_selectscore := 'score(1) + score(2)';
else
l_selectscore := 'null';
end if;
l_query := '
select
"VENUE_ID",
"VENUE_NAME",
"CITY",
"VENUE_NO",
"POSTCODE",
dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
' || l_select_score || ' as score
FROM "GAMEVENUE" i';