【发布时间】:2019-10-11 11:03:51
【问题描述】:
我正在处理递归查询,并且正在处理存储在 varchar(90) 列中的 guid。但是在使用 Postgres 11.1 时,我从 pgAdmin 得到了一个强制转换类型异常
我被困住了,我不知道我能做些什么来解决这个问题,如果有人可以帮助我的话。
https://docs.postgresql.fr/8.4/queries-with.html
with recursive sousSujet(typerefin,coderefin,typerefout,coderefout,type,profondeur,chemin, boucle) as (
SELECT p.typerefin, p.coderefin, p.typerefout , p.coderefout , p.type,1, ARRAY[p.coderefout]::varchar(90)[] ,false
FROM relation p
WHERE p.coderefin='2019094070' and p.typerefin='PROJET'
--union all
union
SELECT p.typerefin, p.coderefin, pr.typerefout, pr.coderefout, p.type ,pr.profondeur+1,
--chemin || pr.coderefout,pr.coderefout = ANY(pr.chemin)
chemin::varchar(90)[] || pr.coderefout,pr.coderefout = ANY(pr.chemin::varchar(90)[])
FROM relation p,sousSujet pr
-- WHERE p.coderefin = pr.coderefout
WHERE p.coderefin = pr.coderefout AND NOT pr.boucle and pr.profondeur < 10
)
SELECT typerefin,coderefin,typerefout,coderefout,type,profondeur
FROM sousSujet
order by coderefout limit 20
ERROR: ERREUR: dans la requête récursive « soussujet », la colonne 7 a le type character varying(90)[] dans le terme non
récursif mais le type global character varying[]
LINE 3: ...oderefin, p.typerefout , p.coderefout , p.type,1, ARRAY[p.co...
^
HINT: Convertit la sortie du terme non récursif dans le bon type.
【问题讨论】:
标签: postgresql