我最近几天厌倦了APEX,我试图在application express中运行一个交互式报告,似乎无法使用我在sql查询中声明的变量。下面是错误,我还包括有效的代码。 get_longlat()函数经过测试,可以返回SDO_GEOMETRY数据类型。
ORA-06550:第7行,第12栏:PLS-00306:错误的数字或类型 调用'||'时的参数ORA-06550:第7行,第1列:PL / SQL: 声明被忽略
DECLARE
l_query VARCHAR2(4096);
l_location SDO_GEOMETRY := get_longlat(v('P2_POSTCODE'));
BEGIN
l_query := '
SELECT
"VENUE_ID",
"VENUE_NAME",
"CITY",
"VENUE_NO",
"POSTCODE",
dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
"DESCRIPTION",
SDO_GEOM.SDO_DISTANCE(G_LOCATION, ' || l_location || ',0.005,''unit=mile'') "G_LOCATION"
FROM "GAMEVENUE"
WHERE (SDO_WITHIN_DISTANCE(G_LOCATION,' || l_location || ',''distance=250 unit=mile'') = ''TRUE'');';
RETURN l_query;
这有效
l_query := '
SELECT
"VENUE_ID",
"VENUE_NAME",
"CITY",
"VENUE_NO",
"POSTCODE",
dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
"DESCRIPTION",
SDO_GEOM.SDO_DISTANCE(G_LOCATION, MDSYS.SDO_GEOMETRY(2001,4326,SDO_POINT_TYPE(-4.1530439,50.371089,NULL),NULL,NULL),0.005,''unit=mile'') "G_LOCATION"
FROM "GAMEVENUE"
WHERE (SDO_WITHIN_DISTANCE(G_LOCATION,SDO_GEOMETRY(2001,4326,SDO_POINT_TYPE(-4.1530439,50.371089,null),null,null),''distance=250 unit=mile'') = ''TRUE'')';
答案 0 :(得分:1)
由于SDO_GEOMETRY
不是char
或number
类型(隐含地显示为char),因此您无法直接使用它。
试试这个:
l_query := '
SELECT
"VENUE_ID",
"VENUE_NAME",
"CITY",
"VENUE_NO",
"POSTCODE",
dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
"DESCRIPTION",
SDO_GEOM.SDO_DISTANCE(G_LOCATION, MDSYS.SDO_GEOMETRY('||l_sdo_gtype||','||l_sdo_srid||',MDSYS.SDO_POINT_TYPE('||l_longitude||','||l_latitude||',NULL),NULL,NULL),0.005,''unit=mile'') "G_LOCATION"
FROM "GAMEVENUE"
WHERE (SDO_WITHIN_DISTANCE(G_LOCATION,SDO_GEOMETRY('||l_sdo_gtype||','||l_sdo_srid||',SDO_POINT_TYPE('||l_longitude||','||l_latitude||',null),null,null),''distance=250 unit=mile'') = ''TRUE'')';
l_sdo_gtype
,l_sdo_srid
,l_longitude
,l_latitude
的类型编号;