Обсуждение: error:

Поиск
Список
Период
Сортировка

error:

От
"chetan N"
Дата:
Hi,
    I am trying to pass array of elements to store procedure, as follows
 
    CREATE TYPE emptype as(
                                                name text,
                                                id integer,
                                                dob date);
 
    Function header looks like this
 
    CREATE OR REPLACE FUNCTION passingEmployeeList(employeeList emptype[])  
    RETURNS SETOF employee AS $$
 
    To execute i am using command
   
    SELECT * from passingEmployeeList(ARRAY[('chethan', 1, '10-05-1983'),('ashok', 2, '10-05-1982')]::emptype[] );
 
    I am getting error as
    ERROR:  could not find array type for data type record
 
 
Regards,
chethan

Re: error:

От
Tom Lane
Дата:
"chetan N" <chetan622@gmail.com> writes:
>     CREATE TYPE emptype as(
>                                                 name text,
>                                                 id integer,
>                                                 dob date);

>     SELECT * from passingEmployeeList(ARRAY[('chethan', 1,
> '10-05-1983'),('ashok', 2, '10-05-1982')]::emptype[] );
>     ERROR:  could not find array type for data type record

That does work in CVS HEAD, but in existing releases you'll need to
spell the array constructor like this:

ARRAY[('chethan', 1,'10-05-1983')::emptype, ('ashok', 2, '10-05-1982')::emptype]

8.3 and before try to determine the array type too soon --- casting the
result of the constructor doesn't help them.

            regards, tom lane