【问题标题】:Query error while working with PL/pgSQL arrays使用 PL/pgSQL 数组时出现查询错误
【发布时间】:2023-03-14 20:25:02
【问题描述】:

我有这个功能:

create or replace function insert_aereo( aereo_type[] ) returns text as $$
begin
   return 'ok';
end
$$ language plpgsql;

这是我创建的参数类型:

create type aereo_type as (codice int, modello varchar, marca varchar);

然后我调用我的函数:

select insert_aereo('{123, "ciao", "pippo"}');

但我收到此错误:

错误:函数 insert_aereo(unknown) 在字符 8 处不是唯一的 提示:无法选择最佳候选函数。您可能需要添加显式类型转换。 声明:select insert_aereo('{123, "ciao", "pippo"}'); 错误:函数 insert_aereo(unknown) 不是唯一的 第 1 行:选择 insert_aereo('{123, "ciao", "pippo"}'); ^ 提示:无法选择最佳候选函数。您可能需要添加显式类型转换。

我该如何解决?我做错了什么?

【问题讨论】:

    标签: sql postgresql plpgsql


    【解决方案1】:

    您对组合类型使用了错误的格式:

    正确的格式是:

    '{"(123, ciao, pippo)", "(...)"}

    见:http://www.postgresql.org/docs/8.4/interactive/rowtypes.html

    或数组[(1,'ciao','pippo')]::t[]

    帕维尔

    【讨论】:

      猜你喜欢
      • 2021-12-25
      • 2012-05-21
      • 2011-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-27
      • 2021-12-28
      • 2019-04-01
      相关资源
      最近更新 更多