我有这样的查询:
final String q =
"SELECT level AS \"sibling_level\", tree.* FROM category_view tree " +
"where tree.child_market = :market " +
"connect by prior tree.cate_xre_id = tree.cate_id " +
"start with tree.cate_id = -1 or tree.cate_id = -18";
final Query query = cqb.createNativeQuery(q, params,
NSISegmentationTreeViewImpl.class);
List<NSISegmentationTreeViewImpl> segList = query.getResultList();
category_view是一个数据库视图。
我有时会:
SQLGrammarException:ORA-00904:&#34; NSISEGMENT0 _&#34;。&#34; SIBLING_LEVEL&#34;:无效标识符
它不确定有时我有好结果有时我有错误。
数据库版本是11
有什么想法吗?
感谢。
查看def:
CREATE OR REPLACE FORCE "CATEGORY_VIEW" ("PARENT_ID", "PARENT_NAME", "CHILD_ID", "CHILD_NAME", "CHILD_TYPE", "CHILD_PRIORITY", "CHILD_MARKET", "CATE_XRE_ID", "CATE_ID") AS
WITH sibling AS
(SELECT
pare.category_id parent_id,
pare.name parent_name,
chld.category_id child_id,
chld.name child_name,
csga.value child_type,
cpra.value child_priority,
cmra.value child_market ,
paxr.sub_category_id cate_xre_id,
pare.category_id cate_id,
)
SELECT
parent_id,
parent_name ,
child_id,
child_name,
child_type,
child_priority,
child_market,
cate_xre_id,
cate_id,
FROM sibling
ORDER BY sibling.child_name;
我删除了不必要的字段,结构是一样的。