sql – 无法确定多态类型,因为输入的类型为“unknown”
发布时间:2020-05-24 10:39:35 所属栏目:MsSql 来源:互联网
导读:我有一个查询,输出为 Could not determine polymorphic type because input has type “unknown” 查询: select ( array_to_string(array_agg(name), , ))::text as name,path from(select fullpath as Path,null as id, a
|
我有一个查询,输出为
查询: select ( array_to_string(array_agg(name),','))::text as name,path
from(select 'fullpath' as Path,null as id,'' as name
from tblabc where key = 'key1' and value = '1'
) as e
group by path;
我有一个postgres数据库 解决方法这里的问题是”名称实际上没有为值指定类型.它是未知类型,PostgreSQL通常会推断出真正的类型,例如你要插入的列或者传递给它的函数.在这种情况下,您将它传递给array_agg,这是一个polymorphc函数.它可以接受伪类型任意元素的输入,这实际上只是意味着“在运行时弄清楚它”. PostgreSQL仍然可以解决它,除了array_to_string实际上并没有将text []作为输入.它需要任何数组 – 另一种多态类型,就像数组的任何元素一样. 因此查询中没有任何内容可以告诉PostgreSQL这是什么类型.它可能猜到你的意思是文字,但它有点太挑剔了.所以它抱怨.该问题简化为: regress=> SELECT array_to_string(array_agg(''),');
ERROR: could not determine polymorphic type because input has type "unknown"
要解决此问题,请编写一个类型文字: TEXT '' AS name 或使用演员表: CAST('' AS text) AS name
或PostgreSQL简写: ''::text 例子: regress=> SELECT array_to_string(array_agg(TEXT ''),');
array_to_string
-----------------
(1 row)
regress=> SELECT array_to_string(array_agg(''::text),');
array_to_string
-----------------
(1 row)
regress=> SELECT array_to_string(array_agg(CAST('' AS text)),');
array_to_string
-----------------
(1 row) (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- sql-server-2005 – 如何才能获得聚簇索引而不是聚簇索引扫
- sql-server – SQL Server包装选择…将查询插入隐式事务吗?
- sql – 仅从多个表中选择相同的列什么东西=某事
- 如何在SQL中使用NOT EXISTS和COMPOSITE KEYS从POJO插入数据
- sql – 存储过程:使用临时表减少代码重复
- data-structures – 关系数据库的高效持久数据结构
- sql – 我的查询运行速度更快,第二次,我该如何阻止?
- sql-server-2008 – 如何加速这个Sql Server Spatial查询?
- ADO.NET EF中的实体修改方法
- SQL Server sql 分组查询问题
