我已阅读与SQL递归查询相关的this useful article。我想在Android和SQLite中做同样的事情。这是原始查询:
WITH RECURSIVE search_path (path_ids, length, is_visited) AS
(
SELECT
ARRAY[node_id, destination_node_id],
link_length,
node_id = destination_node_id
FROM
node_links_view
UNION ALL
SELECT
path_ids || d.destination_node_id,
f.length + d.link_length,
d.destination_node_id = ANY(f.path_ids)
FROM
node_links_view d,
search_path f
WHERE
f.path_ids[array_length(path_ids, 1)] = d.node_id
AND NOT f.is_visited
)
SELECT * FROM search_path
WHERE path_ids[1] = 1 AND path_ids[array_length(path_ids, 1)] = 6
ORDER BY length;
我正在Windows中使用SQLite browser测试查询。但是我得到了这个错误:
near "[array_length(path_ids, 1)]": syntax error:
我想知道这里有什么问题,而SQLite中是否存在array_length
?
如果它没有如何更改查询以使其在SQLite中工作?