views:

39

answers:

1

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?

A: 

You are use a bad formatting for composed types:

correct format is:

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

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

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

Pavel

Pavel Stehule