sql - 大家好,我正在使用 apex 19.1 创建经典报告时遇到一些错误
问题描述
大家好,我正在研究 apex 19.1 在创建经典报告时遇到一些错误,该报告在块下执行时,
declare
vquery varchar2(4000);
BEGIN
if
(:P3_POSTCODE is not null
and
:P3_HUISNR is not null
)
then
vquery :='SELECT * FROM LVV_AANSLUITPUNT where lvv_aansluitpunt.la_post_code = :P3_POSTCODE
and lvv_aansluitpunt.la_huis_nr = :P3_HUISNR and ((lvv_aansluitpunt.la_dat_aanvang is not null
and lvv_aansluitpunt.la_dat_eind is null ) or (lvv_aansluitpunt.la_dat_aanvang is null
and lvv_aansluitpunt.la_dat_eind is null )) and lvv_aansluitpunt.an_code is not null
and lvv_aansluitpunt.vl_id is not null
and not exists (select '*' from lvv_juridische_lever jl where jl.vv_id = lvv_aansluitpunt.vv_id and upper(jl.nv_code) ="B")
and exists (select '*' from lvv_vv_leiding vl where vl.vl_id = lvv_aansluitpunt.vl_id
and ((vl.vl_dat_aanvang is not null and vl.vl_dat_eind is null ) or (vl.vl_dat_aanvang is null and vl.vl_dat_eind is null )))
and exists (select '*' from lvv_vaste_verbinding vv , lvv_soort_artikel sa where vv.vv_id = lvv_aansluitpunt.vv_id and vv.sa_code = sa.sa_code and sa.sa_aansl_drager_j_n = "J")';
else
vquery := 'select distinct sa.sa_code
, sa.sa_type_verbinding
, vv.vv_id
, nvl(vv.vv_lijnbenaming_nw,vv.vv_lijnbenaming)
, vl.vl_id
, vl.vl_lijnbenaming
from lvv_soort_artikel sa
, lvv_vv_leiding vl
, lvv_juridische_lever jl
, lvv_ldm_aansluitpunt la
, lvv_vaste_verbinding vv
where :P3_VV_LIJNBEN =
nvl(vv.vv_lijnbenaming_nw,vv.vv_lijnbenaming)
and vv.vv_id = vl.vv_id
and vv.vv_id = jl.vv_id
and vv.vv_id = la.vv_id
and vv.sa_code = sa.sa_code
and la.an_code is not null
and vl.vl_id is not null
and jl.nv_code <> "B"
and sa.sa_aansl_drager_j_n = "j"
and ((la.la_dat_aanvang is not null
and
la.la_dat_eind is null
)
or
(la.la_dat_aanvang is null
and
la.la_dat_eind is null
))
and ((vl.vl_dat_aanvang is not null
and
vl.vl_dat_eind is null
)
or
(vl.vl_dat_aanvang is null
and
vl.vl_dat_eind is null
))';
end if ;
RETURN vquery;
end;
执行时返回的错误是:- ORA-20999:解析返回的查询导致“ORA-20999:解析 SQL 查询失败!
ORA-06550:第 24 行,第 40 列:ORA-00904:“j”:无效标识符
”。解决方案
在 oracle 中,单引号用于字符串文字。双引号用于表名/列名。
用单引号替换查询中文字 'j' 的双引号。如果字符串 vquery 有换行符,则每行应包含在字符串中,并且必须连接在一起。
else
vquery := 'select distinct sa.sa_code '||chr(10)||
', sa.sa_type_verbinding '||chr(10)||
', vv.vv_id '||chr(10)||
', nvl(vv.vv_lijnbenaming_nw,vv.vv_lijnbenaming) '||chr(10)||
', vl.vl_id '||chr(10)||
', vl.vl_lijnbenaming '||chr(10)||
' from lvv_soort_artikel sa '||chr(10)||
' , lvv_vv_leiding vl '||chr(10)||
' , lvv_juridische_lever jl '||chr(10)||
' , lvv_ldm_aansluitpunt la '||chr(10)||
要为字符串文字转义单引号,请使用两个单引号而不是一个,如下所示:
'and jl.nv_code <> ''B'''||chr(10)||
'and sa.sa_aansl_drager_j_n = ''j'''||chr(10)||
推荐阅读
- jsf-2 - 将参数传递给复合组件的验证器
- sql - 使用 Postgres regexp_replace 屏蔽查询字符串参数值
- d3.js - 将 tspan 放在矩形 D3JS SVG 内
- google-apps-script - 使用脚本从 Google 表单打开一个新的 Google 电子表格文件
- azure - 如何更改现有 Azure 应用程序网关的 VNet 和子网?
- visual-studio - 将 Unity 应用程序提交到 Windows 商店
- rest - HATEOAS 不会增加 HTTP 请求吗?
- list - 如何在列表中搜索特定元素
- javascript - 如何使用 Eventbrite Api 查询特定城市特定日期的所有事件?
- android - 为什么真实设备上的xamarin android应用程序总是抛出错误但在模拟器上工作