开发者

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开发者_如何学Python(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)", "(...)"}

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

or ARRAY[(1,'ciao','pippo')]::t[]

Pavel

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜