[英]Query error while working with PL/pgSQL arrays
I have this function: 我有这个功能:
create or replace function insert_aereo( aereo_type[] ) returns text as $$
begin
return 'ok';
end
$$ language plpgsql;
and this is the parameter type that I created: 这是我创建的参数类型:
create type aereo_type as (codice int, modello varchar, marca varchar);
Then I call my function: 然后我调用我的函数:
select insert_aereo('{123, "ciao", "pippo"}');
but I get this error: 但是我得到这个错误:
ERROR: function insert_aereo(unknown) is not unique at character 8 HINT: Could not choose a best candidate function. You might need to add explicit type casts. STATEMENT: select insert_aereo('{123, "ciao", "pippo"}'); ERROR: function insert_aereo(unknown) is not unique LINE 1: select insert_aereo('{123, "ciao", "pippo"}'); ^ HINT: Could not choose a best candidate function. You might need to add explicit type casts.
How can I fix it? 我该如何解决? What am I doing wrong?
我究竟做错了什么?
You are using a bad format for composed types: 您对组合类型使用了错误的格式:
The correct format is: 正确的格式是:
'{"(123, ciao, pippo)", "(...)"} '{“(123,ciao,pippo)”,“(...)”}
see: http://www.postgresql.org/docs/8.4/interactive/rowtypes.html 参见: http : //www.postgresql.org/docs/8.4/interactive/rowtypes.html
or ARRAY[(1,'ciao','pippo')]::t[] 或ARRAY [(1,'ciao','pippo')] :: t []
Pavel 帕维尔
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.