Search Postgresql Archives

variadic array arguments, can it work?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Hi,

I was trying to write a variadic function where the arguments themselves are arrays, but calling it does not seem to work. I couldn't find documentation mentioning this restriction

postgres=# create or replace function foo(variadic args integer[][]) returns integer
as $$
begin return args[2][2]; end;
$$ language plpgsql;

Now I can call the function using variadic:

postgres=# select foo(variadic array[array[1,2],array[3,4]]);
 foo
-----
   4
(1 row)

but I cannot call it in the normal way...

postgres=# select foo( array[1,2] , array[3,4] );
ERROR:  function foo(integer[], integer[]) does not exist at character 8
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
STATEMENT:  select foo( array[1,2] , array[3,4] );
ERROR:  function foo(integer[], integer[]) does not exist
LINE 1: select foo( array[1,2] , array[3,4] );
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

I suspect this has to do something with multiple dimensional arrays not truly being arrays of arrays...


Kind regards,

Ingmar Brouns


                                                   version                                               
   
----------------------------------------------------------------------------------------------------------
----
 PostgreSQL 9.1.1 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.6.1 20110908 (Red Hat 4.6.1-9), 64-
bit
(1 row)


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux